/* ============================================================
   MAX MINES — minesweeper in the OX house style
   ============================================================
   The palette, buttons, screens and overlay are deliberately the same
   shapes as ../ox/styles.css: the two games sit behind one picker and
   should not feel like two different websites. They are copied rather
   than shared because ox/ is content-hash stamped per roster and its
   stylesheet is on its own cache lifecycle.
   ============================================================ */

:root {
  --bg:        #1b1033;
  --bg-2:      #2b1657;
  --ink:       #fff6e5;
  --pa:        #ffd23f;
  --pb:        #4ecdc4;
  --hot:       #ff5d8f;
  --line:      rgba(255, 246, 229, 0.16);
  --cell:      rgba(255, 255, 255, 0.06);
  --shadow:    0 10px 0 rgba(0,0,0,.28);

  /* One number drives the whole board: every cell, glyph and number is a
     fraction of it, so a 16-wide board shrinks its type to match instead
     of overflowing. JS never touches sizing. */
  --board-w: min(92vw, 58dvh, 520px);
  --cols: 8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg) 62%),
    var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(3px 3px at 12% 22%, var(--pa) 50%, transparent 51%),
    radial-gradient(3px 3px at 82% 14%, var(--pb) 50%, transparent 51%),
    radial-gradient(2px 2px at 68% 78%, var(--hot) 50%, transparent 51%),
    radial-gradient(2px 2px at 24% 84%, var(--pb) 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 56%, var(--pa) 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 58%, var(--hot) 50%, transparent 51%);
  opacity: .5;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateY(-14px); } }

#app { position: relative; height: 100%; }
@supports (height: 100dvh) { #app { height: 100dvh; } }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding:
    calc(24px + env(safe-area-inset-top, 0px))
    calc(20px + env(safe-area-inset-right, 0px))
    calc(24px + env(safe-area-inset-bottom, 0px))
    calc(20px + env(safe-area-inset-left, 0px));
  text-align: center;
}
.screen.is-active { display: flex; animation: screenIn .32s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- title ---------- */
.logo {
  margin: 0;
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  letter-spacing: .02em;
  line-height: .92;
  font-size: clamp(2.6rem, 13vw, 5.4rem);
  display: flex;
  flex-direction: column;
}
.logo-word { display: block; text-shadow: 0 5px 0 rgba(0,0,0,.35); }
.logo-word--a { color: var(--pa); transform: rotate(-3deg); }
.logo-word--b { color: var(--pb); transform: rotate(2.5deg); }

.tagline {
  margin: -6px 0 0;
  font-weight: 700;
  opacity: .6;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .8rem;
}

.title-faces { display: flex; align-items: flex-end; }
.title-face {
  width: clamp(96px, 30vw, 170px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.45));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%     { transform: translateY(-12px) rotate(3deg); }
}

/* ---------- buttons ---------- */
.heading {
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  margin: 0;
  text-shadow: 0 4px 0 rgba(0,0,0,.3);
}

.stack { display: flex; flex-direction: column; gap: 14px; width: min(340px, 88vw); }

.btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1.05rem, 4.6vw, 1.4rem);
  letter-spacing: .04em;
  color: #2a1350;
  background: var(--ink);
  border: 0;
  border-radius: 18px;
  padding: 16px 26px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  width: 100%;
  text-decoration: none;
}
.btn small {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .55;
}
.btn:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0,0,0,.28); }
.btn--big {
  width: min(300px, 78vw);
  background: var(--hot);
  color: #fff;
  font-size: clamp(1.4rem, 6vw, 2rem);
  padding: 18px 32px;
}
.btn--ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  opacity: .6;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  width: auto;
  padding: 10px 18px;
  min-height: 44px;
  justify-content: center;
}
.btn--ghost:active { transform: none; opacity: 1; }
button { touch-action: manipulation; }

/* ---------- mine picker ---------- */
.picker { display: flex; gap: clamp(10px, 3vw, 20px); flex-wrap: wrap; justify-content: center; }
.pick-card {
  background: var(--cell);
  border: 3px solid var(--line);
  border-radius: 26px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--ink);
  font-family: 'Luckiest Guy', cursive;
  font-size: 1rem;
  letter-spacing: .06em;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
  width: clamp(104px, 27vw, 140px);
}
.pick-card .sprite {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  line-height: 1;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.4));
}
/* A roster of real PNGs can be dropped into assets/mines/ later; the game
   reads `img` off the sprite definition and prefers it over the emoji. */
.pick-card img, .cell img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.pick-card:active { transform: scale(.95); }
@media (hover: hover) and (pointer: fine) {
  .pick-card:hover { border-color: var(--pa); background: rgba(255,210,63,.12); }
}
.pick-card:is(:active, :focus-visible) { border-color: var(--pa); background: rgba(255,210,63,.12); }
.pick-card.is-chosen { border-color: var(--pa); background: rgba(255,210,63,.16); }

/* ---------- game ---------- */
.screen--game { justify-content: center; gap: clamp(12px, 3vh, 26px); }
.screen--game .status { margin-bottom: auto; }
.screen--game .game-actions { margin-top: auto; }

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 4vw, 26px);
  width: var(--board-w);
}
.status-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cell);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 8px 14px;
  min-width: 84px;
  justify-content: center;
}
.status-box b { font-family: 'Luckiest Guy', cursive; font-size: 1.3rem; letter-spacing: .04em; }
.status-sprite { font-size: 1.2rem; line-height: 1; }

/* The classic smiley slot. It is Max, and tapping it starts a new game. */
.face-btn {
  background: transparent;
  border: 3px solid var(--line);
  border-radius: 50%;
  padding: 6px;
  cursor: pointer;
  width: clamp(62px, 17vw, 84px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transition: transform .14s ease, border-color .2s ease;
}
.face-btn img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
.face-btn:active { transform: scale(.92); }
.face-btn.is-won  { border-color: var(--pa); animation: shake .6s ease-in-out infinite; }
.face-btn.is-lost { border-color: var(--hot); }
.face-btn.is-lost img { filter: grayscale(1) drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
/* Held breath while a square is under the finger — the classic "ooh" face. */
.face-btn.is-worried { transform: scale(.94) rotate(-4deg); }

/* `flex: none` matters: the game screen is a flex column, and without it
   the board is the thing that gets shrunk, squashing the last rows into
   slivers instead of letting the aspect ratio hold. */
.board-wrap { display: grid; place-items: center; flex: none; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  /* Rows must be declared too. With only columns, the implicit rows size to
     their content and the last row of a big board collapses to a sliver. */
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: max(2px, calc(var(--board-w) / var(--cols) * .06));
  width: var(--board-w);
  height: calc(var(--board-w) / var(--cols) * var(--rows));
  flex: none;
}

.cell {
  border: 0;
  border-radius: max(6px, calc(var(--board-w) / var(--cols) * .2));
  background: rgba(255,255,255,.15);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 2px var(--line), 0 3px 0 rgba(0,0,0,.3);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  font-family: 'Luckiest Guy', cursive;
  font-size: calc(var(--board-w) / var(--cols) * .52);
  line-height: 1;
  color: var(--ink);
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.cell:not(.is-open):active { background: rgba(255,255,255,.2); transform: translateY(2px); }

.cell.is-open {
  background: rgba(8, 3, 20, .38);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.45);
  cursor: default;
}
.cell.is-open.just-opened { animation: openPop .26s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes openPop { from { transform: scale(.7); opacity: .3; } }

/* Classic number colours, pulled toward the palette so they sit on purple. */
.cell[data-n="1"] { color: #7db7ff; }
.cell[data-n="2"] { color: #8be08b; }
.cell[data-n="3"] { color: #ff8f8f; }
.cell[data-n="4"] { color: #c79bff; }
.cell[data-n="5"] { color: #ffb066; }
.cell[data-n="6"] { color: var(--pb); }
.cell[data-n="7"] { color: var(--ink); }
.cell[data-n="8"] { color: #ff6fae; }

.cell .sprite { font-size: .84em; line-height: 1; }
.cell.is-flagged .sprite { animation: plant .28s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes plant { from { transform: scale(0) rotate(-40deg); } 60% { transform: scale(1.2) rotate(8deg); } }

.cell.is-mine { background: rgba(255, 93, 143, .18); box-shadow: inset 0 0 0 2px rgba(255,93,143,.5); }
.cell.is-boom { background: var(--hot); animation: boom .5s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes boom { 0% { transform: scale(.6); } 55% { transform: scale(1.3); } 100% { transform: scale(1); } }
.cell.is-wrong .sprite { opacity: .45; filter: grayscale(1); }

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(-7deg) scale(1.06); }
  25%      { transform: translateX(-4px) rotate(7deg) scale(1.1); }
  50%      { transform: translateX(4px) rotate(-5deg) scale(1.06); }
  75%      { transform: translateX(-3px) rotate(6deg) scale(1.1); }
}
@keyframes wobble { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }

.game-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 2px; }

/* Flag mode. A tablet has no right-click, so this toggle is the primary
   way in and the long-press is the shortcut for whoever finds it. */
.btn--flag {
  background: transparent;
  color: var(--ink);
  border: 3px solid var(--line);
  box-shadow: none;
  font-size: .95rem;
  padding: 10px 18px;
  width: auto;
  min-height: 44px;
  flex-direction: row;
  gap: 8px;
}
.btn--flag:active { transform: none; }
.btn--flag[aria-pressed="true"] {
  background: var(--pa);
  color: #2a1350;
  border-color: var(--pa);
}
.flag-glyph { font-size: 1.1rem; line-height: 1; }

.btn--mute {
  background: transparent;
  border: 3px solid var(--line);
  box-shadow: none;
  font-size: 1.15rem;
  line-height: 1;
  padding: 10px 14px;
  width: auto;
  min-height: 44px;
  min-width: 48px;
}
.btn--mute:active { transform: none; }
.btn--mute.is-muted { opacity: .5; }

.flag-hint {
  margin: 0;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 900;
  opacity: .35;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  transition: opacity .3s ease;
}
.flag-hint.is-gone { opacity: 0; }

/* ---------- scores ---------- */
.scores {
  width: min(460px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 54dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--cell);
  border: 3px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  text-align: left;
}
.score-row .sprite { font-size: 1.6rem; line-height: 1; }
.score-row .score-main { flex: 1; }
.score-row .score-size {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.05rem;
  letter-spacing: .05em;
}
.score-row .score-sub {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .5;
  font-weight: 900;
}
.score-row .score-time {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.5rem;
  color: var(--pa);
}
.score-row.is-none .score-time { color: var(--ink); opacity: .3; font-size: 1.1rem; }
.scores-empty { margin: 0; opacity: .55; font-weight: 700; }
.scores-note {
  margin: 0;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 900;
  opacity: .35;
}

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(12, 6, 26, .84);
  backdrop-filter: blur(10px);
  animation: screenIn .28s ease both;
  padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }

.result-faces { display: flex; align-items: center; }
.result-face {
  width: clamp(112px, 32vw, 180px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.5));
}
.result-face.is-winner { animation: shake .58s ease-in-out infinite; }
.result-face.is-loser  { transform: scale(.85); filter: grayscale(1) drop-shadow(0 10px 14px rgba(0,0,0,.5)); }

.result-text {
  margin: 0;
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  font-size: clamp(1.8rem, 9vw, 3.2rem);
  text-shadow: 0 5px 0 rgba(0,0,0,.35);
  line-height: 1;
}
.result-text.won  { color: var(--pa); }
.result-text.lost { color: var(--hot); }
.result-sub { margin: -6px 0 0; font-weight: 700; opacity: .7; font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- tablet ----------
   Same breakpoint as ox/. Without it the board sits phone-sized in the
   middle of an iPad, which is what the 30 Jul session fixed there.      */
@media (min-width: 700px) and (min-height: 600px) {
  :root { --board-w: min(78vw, 64dvh, 620px); }
  .title-face  { width: 190px; }
  .logo        { font-size: 5.6rem; }
  .stack       { width: min(380px, 80vw); }
  .pick-card   { width: 150px; }
  .result-face { width: clamp(180px, 26vmin, 230px); }
  .result-text { font-size: clamp(3rem, 6vmin, 4rem); }
  .screen--game .status       { margin-bottom: 0; }
  .screen--game .game-actions { margin-top: 0; }
  .btn--flag   { font-size: 1.05rem; padding: 12px 22px; }
  .flag-hint   { font-size: .78rem; }
}
