/* =========================================================================
   Breathing + 2048 + Minesweeper
   ========================================================================= */

/* ===================== BREATHING ===================== */
.breath-tool {
  height: 100%;
  overflow-y: auto;
  padding: 28px max(40px, calc((100% - 900px) / 2)) 60px;
}
.breath-head {
  margin-bottom: 24px;
}
.breath-head h1 {
  margin: 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.breath-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.breath-stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 36px 0 28px;
  gap: 24px;
}
.breath-circle-wrap {
  width: 320px; height: 320px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.breath-circle {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  transform-origin: center center;
}
.breath-label {
  position: relative;
  text-align: center;
  z-index: 2;
  pointer-events: none;
}
.breath-cue {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-hi);
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.breath-count {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
  font-variant-numeric: tabular-nums;
}
html.light .breath-count { color: rgba(0,0,0,0.7); text-shadow: none; }
html.light .breath-cue { text-shadow: none; }

.breath-controls {
  display: flex; gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.breath-primary {
  padding: 12px 28px;
  font-size: 15px;
}

.breath-pickers {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
@media (max-width: 720px) { .breath-pickers { grid-template-columns: 1fr; } }
.breath-picker-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breath-pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.breath-pattern-card {
  text-align: left;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  cursor: pointer; font-family: inherit;
  color: var(--text-md);
  transition: all 120ms;
}
.breath-pattern-card:hover:not(:disabled) { border-color: var(--text-muted); }
.breath-pattern-card.is-active {
  border-color: hsl(168, 60%, 50%);
  background: hsla(168, 60%, 50%, 0.06);
}
.breath-pattern-card:disabled { opacity: 0.5; cursor: not-allowed; }
.breath-pattern-name {
  font-size: 14px; font-weight: 700;
  color: var(--text-hi);
}
.breath-pattern-tag {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 4px 0 8px;
  line-height: 1.5;
}
.breath-pattern-rhythm {
  display: flex; gap: 5px;
}
.breath-pattern-phase {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-bg);
  font-size: 11px; font-weight: 700;
  color: var(--text-lo);
  font-variant-numeric: tabular-nums;
}
.breath-pattern-phase.phase-in   { color: hsl(168, 60%, 50%); }
.breath-pattern-phase.phase-out  { color: hsl(212, 70%, 60%); }
.breath-pattern-phase.phase-hold { color: hsl(258, 60%, 65%); }

.breath-cycles {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
}
.breath-cycles input[type=range] {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 6px;
  background: var(--color-bg);
  border-radius: 999px;
  outline: none;
}
.breath-cycles input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: hsl(168, 60%, 50%);
  cursor: pointer;
  border: 3px solid var(--color-surface);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.breath-cycles input::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 999px;
  background: hsl(168, 60%, 50%);
  cursor: pointer;
  border: 3px solid var(--color-surface);
}
.breath-cycles-value {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.breath-cycles-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.breath-cycles-time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}


/* ===================== 2048 ===================== */
.g2048-tool {
  height: 100%;
  overflow-y: auto;
  padding: 24px max(32px, calc((100% - 540px) / 2)) 60px;
}
.g2048-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.g2048-head h1 {
  margin: 0;
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.g2048-head p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.g2048-head kbd {
  padding: 1px 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
}
.g2048-scores {
  display: flex; gap: 8px;
}
.g2048-score {
  padding: 8px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  min-width: 78px;
  text-align: center;
}
.g2048-score-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
}
.g2048-score-value {
  font-size: 22px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-hi);
  letter-spacing: -0.02em;
}

.g2048-actions {
  display: flex; gap: 8px;
  margin-bottom: 14px;
}

.g2048-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 10px;
  touch-action: none;
}
.g2048-cells, .g2048-tiles {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
}
.g2048-cell {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
}
html.light .g2048-cell { background: rgba(0,0,0,0.04); }
.g2048-tiles { pointer-events: none; }
.g2048-tile {
  grid-column-start: calc(var(--col) + 1);
  grid-row-start: calc(var(--row) + 1);
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-weight: 800;
  font-size: clamp(20px, 5vw, 36px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  transition: transform 120ms ease;
  color: #fff;
}
.g2048-tile.is-spawned { animation: g2048Spawn 200ms ease-out; }
.g2048-tile.is-merged  { animation: g2048Merge 200ms ease-out; }
@keyframes g2048Spawn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes g2048Merge {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Tile colors — escalating warmth */
.g2048-tile.v-2     { background: hsl(36, 30%, 88%); color: #5b4633; font-size: clamp(22px, 5vw, 36px); }
.g2048-tile.v-4     { background: hsl(36, 50%, 82%); color: #5b4633; }
.g2048-tile.v-8     { background: hsl(28, 80%, 65%); }
.g2048-tile.v-16    { background: hsl(20, 80%, 60%); }
.g2048-tile.v-32    { background: hsl(12, 80%, 60%); }
.g2048-tile.v-64    { background: hsl(0, 80%, 58%); }
.g2048-tile.v-128   { background: hsl(45, 80%, 55%); font-size: clamp(18px, 4.4vw, 32px); }
.g2048-tile.v-256   { background: hsl(45, 85%, 52%); font-size: clamp(18px, 4.4vw, 32px); }
.g2048-tile.v-512   { background: hsl(48, 88%, 50%); font-size: clamp(18px, 4.4vw, 32px); }
.g2048-tile.v-1024  { background: hsl(168, 55%, 45%); font-size: clamp(16px, 4vw, 28px); }
.g2048-tile.v-2048  { background: hsl(168, 70%, 42%); font-size: clamp(16px, 4vw, 28px); box-shadow: 0 0 24px hsla(168, 70%, 42%, 0.5); }
.g2048-tile.v-4096,
.g2048-tile.v-8192,
.g2048-tile.v-16384 { background: hsl(258, 60%, 55%); font-size: clamp(14px, 3.6vw, 26px); }

.g2048-overlay {
  position: absolute; inset: 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
  animation: g2048Fade 240ms;
}
@keyframes g2048Fade { from { opacity: 0; } to { opacity: 1; } }
.g2048-overlay-card {
  text-align: center;
  padding: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  max-width: 320px;
}
.g2048-overlay-card > .material-symbols-outlined {
  font-size: 48px;
  color: var(--color-primary);
}
.g2048-overlay-card h2 {
  margin: 8px 0 4px;
  font-size: 22px; font-weight: 700;
  color: var(--text-hi);
}
.g2048-overlay-card p {
  margin: 0 0 16px;
  font-size: 13px; color: var(--text-muted);
}
.g2048-overlay-actions { display: flex; gap: 8px; justify-content: center; }


/* ===================== MINESWEEPER ===================== */
.ms-tool {
  height: 100%;
  overflow: auto;
  padding: 24px 32px 60px;
}
.ms-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}
.ms-head h1 {
  margin: 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.ms-head p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.ms-difficulty {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.ms-diff {
  text-align: left;
  padding: 8px 14px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer; font-family: inherit;
  color: var(--text-lo);
  transition: all 120ms;
  min-width: 130px;
}
.ms-diff:hover { border-color: var(--color-primary); }
.ms-diff.is-active {
  background: rgba(var(--primary-rgb, 127,13,242), 0.08);
  border-color: var(--color-primary);
  color: var(--text-hi);
}
.ms-diff-name {
  font-size: 13px; font-weight: 700;
  color: var(--text-hi);
}
.ms-diff-spec {
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.ms-diff-best {
  font-size: 10.5px;
  color: hsl(168, 60%, 50%);
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.ms-status {
  display: flex; align-items: center; justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 10px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.ms-status-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 18px; font-weight: 700;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
  min-width: 76px;
}
.ms-status-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
}
.ms-status-face {
  background: transparent; border: 0; cursor: pointer;
  font-size: 28px;
  padding: 2px;
  transition: transform 120ms;
}
.ms-status-face:hover { transform: scale(1.15); }

.ms-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1px;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  user-select: none;
  touch-action: manipulation;
}
.ms-cell {
  width: 28px; height: 28px;
  background: var(--color-surface);
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-hi);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background 80ms;
}
.ms-cell:not(.is-revealed):hover {
  background: rgba(var(--primary-rgb, 127,13,242), 0.1);
}
.ms-cell.is-revealed {
  background: var(--color-bg);
  cursor: default;
}
.ms-cell.is-mine {
  background: hsl(8, 78%, 58%);
}
.ms-cell.is-flagged {
  font-size: 14px;
}

.ms-result {
  display: flex; align-items: center; gap: 12px;
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  flex-wrap: wrap;
  justify-content: center;
}
.ms-result > .material-symbols-outlined {
  font-size: 24px;
  color: var(--color-primary);
}
.ms-result strong {
  font-size: 14px;
  color: var(--text-hi);
  flex: 1;
}
