/* ------------------------------------------------------------------
   MINEFIELD / 扫雷行动
   A small, deliberate game interface.
------------------------------------------------------------------- */

:root {
  --bg: #071013;
  --bg-deep: #040b0e;
  --surface: #0b181d;
  --surface-raised: #102229;
  --ink: #edf4ef;
  --ink-soft: #c9d8d2;
  --muted: #849893;
  --dim: #5a6f6b;
  --line: rgba(174, 208, 197, 0.14);
  --line-strong: rgba(174, 208, 197, 0.24);
  --mint: #9be8c9;
  --mint-strong: #63d8b3;
  --coral: #ff7559;
  --coral-soft: #ff9b84;
  --gold: #e8c77b;
  --font-sans: "Avenir Next", Avenir, "Segoe UI Variable", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius-lg: 26px;
  --radius-md: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- atmosphere ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(23, 56, 55, 0.4), transparent 60%),
    linear-gradient(180deg, #081418 0%, #050d10 58%, #040a0c 100%);
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(168, 207, 194, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 207, 194, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.55) 55%, transparent 92%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.55) 55%, transparent 92%);
}

.glow {
  position: absolute;
  width: 680px;
  height: 680px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
}

.glow-mint {
  top: -390px;
  left: 5%;
  background: #2fa58b;
}

.glow-coral {
  top: 32%;
  right: -460px;
  width: 560px;
  height: 560px;
  opacity: 0.1;
  background: #d9583b;
}

/* ---------- shell ---------- */

.app {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 32px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 44px;
  animation: revealDown 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(155, 232, 201, 0.26);
  border-radius: 12px;
  background:
    radial-gradient(circle at 32% 20%, rgba(155, 232, 201, 0.16), transparent 55%),
    #0a181c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: var(--mint);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.brand-mark circle:not(.brand-glint) {
  fill: var(--coral);
  stroke: var(--coral);
}

.brand-mark .brand-glint {
  fill: #ffd9cf;
  stroke: none;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.3;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.34em;
  line-height: 1.4;
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-code {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.site-code span {
  margin: 0 5px;
  color: rgba(155, 232, 201, 0.48);
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(8, 20, 23, 0.55);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.sound-toggle:hover {
  color: var(--ink-soft);
  border-color: var(--line-strong);
  background: rgba(18, 36, 41, 0.65);
}

.sound-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-toggle .sound-off {
  display: none;
}

.sound-toggle[aria-pressed="false"] .sound-on {
  display: none;
}

.sound-toggle[aria-pressed="false"] .sound-off {
  display: block;
}

.sound-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 22px;
  align-items: start;
  margin-top: 28px;
}

.game-card {
  position: relative;
  min-width: 0;
  padding: 30px 32px 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 85% at 88% -12%, rgba(76, 139, 123, 0.11), transparent 56%),
    linear-gradient(150deg, rgba(18, 35, 41, 0.96) 0%, rgba(9, 22, 27, 0.98) 60%, rgba(7, 17, 21, 0.99) 100%);
  box-shadow:
    0 34px 90px -30px rgba(0, 0, 0, 0.86),
    0 2px 0 rgba(255, 255, 255, 0.025) inset;
  animation: cardIn 0.7s 0.05s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-card::before {
  position: absolute;
  top: 0;
  left: 9%;
  width: 42%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(155, 232, 201, 0.5), transparent);
}

.game-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--mint);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  line-height: 1.5;
}

.eyebrow-divider {
  color: rgba(155, 232, 201, 0.32);
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(155, 232, 201, 0.08), 0 0 12px rgba(155, 232, 201, 0.6);
  animation: breathe 2.8s ease-in-out infinite;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 3.6vw, 46px);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 1.06;
}

h1 span {
  margin-left: 0.18em;
  color: transparent;
  font-weight: 550;
  -webkit-text-stroke: 1px rgba(237, 244, 239, 0.36);
}

.best-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 104px;
  padding: 3px 0 3px 20px;
  border-left: 1px solid var(--line);
}

.best-badge span {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.18em;
}

.best-badge strong {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ---------- difficulty ---------- */

.levels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(174, 208, 197, 0.1);
  border-radius: var(--radius-md);
  background: rgba(4, 12, 15, 0.6);
}

.level {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.level:hover {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.028);
}

.level.is-active {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(155, 232, 201, 0.13), rgba(155, 232, 201, 0.045));
  box-shadow:
    inset 0 0 0 1px rgba(155, 232, 201, 0.2),
    0 8px 20px -16px rgba(0, 0, 0, 0.9);
}

.level-index {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  transition: color 0.18s ease;
}

.level.is-active .level-index {
  color: var(--mint);
}

.level-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.level-copy strong {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.level-copy small {
  overflow: hidden;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level.is-active .level-copy small {
  color: rgba(155, 232, 201, 0.7);
}

/* ---------- hud ---------- */

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  margin: 19px 3px 13px;
}

.readout {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.readout-time {
  justify-content: flex-end;
  text-align: right;
}

.readout-icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: rgba(155, 232, 201, 0.62);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.readout-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.readout-copy span {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.13em;
  line-height: 1.35;
}

.readout-copy strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(20px, 2.2vw, 25px);
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.readout-time .readout-copy {
  align-items: flex-end;
}

.reset-button {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(155, 232, 201, 0.22);
  border-radius: 50%;
  color: var(--ink-soft);
  background:
    radial-gradient(circle at 40% 28%, rgba(155, 232, 201, 0.1), transparent 55%),
    #0d2024;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 8px 24px -12px rgba(0, 0, 0, 0.75);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.reset-button:hover {
  border-color: rgba(155, 232, 201, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 0 0 4px rgba(155, 232, 201, 0.045),
    0 8px 24px -12px rgba(0, 0, 0, 0.75);
  transform: translateY(-1px);
}

.reset-button:active {
  transform: scale(0.96);
}

.reset-button .face {
  width: 34px;
  height: 34px;
  overflow: visible;
}

.face .face-bg {
  fill: rgba(4, 12, 14, 0.65);
  stroke: rgba(155, 232, 201, 0.14);
  stroke-width: 1;
}

.face g {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.face g circle {
  fill: currentColor;
  stroke: none;
}

.face-lost,
.face-won {
  display: none;
}

.game-card.is-lost .face-normal,
.game-card.is-won .face-normal {
  display: none;
}

.game-card.is-lost .face-lost {
  display: block;
  color: var(--coral-soft);
}

.game-card.is-won .face-won {
  display: block;
  color: var(--mint);
}

.game-card.is-lost .reset-button {
  border-color: rgba(255, 117, 89, 0.42);
}

.game-card.is-won .reset-button {
  border-color: rgba(155, 232, 201, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 5px rgba(155, 232, 201, 0.06),
    0 0 32px rgba(155, 232, 201, 0.16);
}

.reset-ring {
  position: absolute;
  inset: -6px;
  border: 1px dotted rgba(155, 232, 201, 0.16);
  border-radius: 50%;
  pointer-events: none;
  transition: border-color 0.2s ease, transform 0.35s ease;
}

.reset-button:hover .reset-ring {
  border-color: rgba(155, 232, 201, 0.32);
  transform: rotate(18deg);
}

/* ---------- board ---------- */

.board-shell {
  position: relative;
  border: 1px solid rgba(174, 208, 197, 0.13);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(4, 12, 15, 0.48), rgba(3, 9, 12, 0.64));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025),
    inset 0 0 50px rgba(0, 0, 0, 0.22);
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.board-shell::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.055) 4px
  );
  opacity: 0.38;
}

.board-scroller {
  position: relative;
  z-index: 1;
  padding: 13px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: rgba(121, 162, 151, 0.34) transparent;
}

.board-scroller::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.board-scroller::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: rgba(121, 162, 151, 0.35);
  background-clip: content-box;
}

.board-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.board-edge {
  position: absolute;
  top: 1px;
  bottom: 1px;
  z-index: 3;
  width: 28px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.board-edge-left {
  left: 1px;
  background: linear-gradient(90deg, rgba(5, 13, 16, 0.88), rgba(5, 13, 16, 0));
  border-radius: 15px 0 0 15px;
}

.board-edge-right {
  right: 1px;
  background: linear-gradient(270deg, rgba(5, 13, 16, 0.88), rgba(5, 13, 16, 0));
  border-radius: 0 15px 15px 0;
}

.board-shell.can-scroll-left .board-edge-left,
.board-shell.can-scroll-right .board-edge-right {
  opacity: 1;
}

.board {
  --cell: 34px;
  --gap: 5px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 9), var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  width: max-content;
  margin: 0 auto;
  padding: 0;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: max(2px, calc(var(--cell) * 0.1));
  color: var(--ink-soft);
  background:
    linear-gradient(145deg, #2a3e46 0%, #1d2e35 52%, #17262d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.105),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 1px 1px rgba(0, 0, 0, 0.14);
  font-family: var(--font-mono);
  font-size: calc(var(--cell) * 0.54);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.13s ease, box-shadow 0.13s ease, transform 0.07s ease;
}

.cell::before {
  position: absolute;
  inset: 1px;
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.board:not(.is-over) .cell:not(.is-open, .is-flagged):hover {
  background:
    linear-gradient(145deg, #344d56 0%, #253a43 52%, #1c3038 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 0 1px rgba(155, 232, 201, 0.16),
    0 1px 2px rgba(0, 0, 0, 0.18);
}

.cell:active {
  transform: scale(0.955);
}

.cell:focus-visible {
  z-index: 4;
  outline: 2px solid var(--mint);
  outline-offset: 1px;
}

.cell.is-open {
  color: var(--muted);
  background: #0a171c;
  box-shadow:
    inset 0 0 0 1px rgba(174, 208, 197, 0.055),
    inset 0 2px 4px rgba(0, 0, 0, 0.22);
  cursor: default;
  animation: cellOpen 0.16s ease both;
}

.cell.is-open::before {
  display: none;
}

.cell.is-open:active {
  transform: none;
}

.board.is-over .cell.is-open:not(.is-trigger) {
  animation: none;
}

.board.is-flag-mode .cell:not(.is-open, .is-flagged) {
  cursor: crosshair;
}

.cell.is-flagged {
  color: var(--coral);
  background:
    radial-gradient(circle at 42% 28%, rgba(255, 117, 89, 0.09), transparent 58%),
    linear-gradient(145deg, #2a3e46 0%, #1b2c33 55%, #16252b 100%);
}

.cell.is-flagged .icon {
  filter: drop-shadow(0 0 5px rgba(255, 117, 89, 0.28));
}

.cell .icon {
  position: relative;
  z-index: 1;
  display: block;
  width: 64%;
  height: 64%;
  pointer-events: none;
}

.cell .icon-flag {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cell .icon-flag .flag-fill {
  fill: currentColor;
  stroke: none;
}

.cell .icon-mine {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
}

.cell .icon-mine .mine-core {
  fill: currentColor;
  stroke: none;
}

.cell .icon-mine .mine-glint {
  fill: rgba(3, 10, 12, 0.82);
  stroke: none;
}

/* number colours */
.cell[data-number="1"] { color: #77c6ff; }
.cell[data-number="2"] { color: #83dfad; }
.cell[data-number="3"] { color: #ff9480; }
.cell[data-number="4"] { color: #bfa3ff; }
.cell[data-number="5"] { color: #f4c96f; }
.cell[data-number="6"] { color: #79dede; }
.cell[data-number="7"] { color: #d6ddd8; }
.cell[data-number="8"] { color: #9baab4; }

.cell.is-mine {
  color: var(--coral-soft);
  background: rgba(255, 117, 89, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 117, 89, 0.12);
}

.cell.is-mine .icon-mine {
  width: 58%;
  height: 58%;
}

.cell.is-trigger {
  color: #2b0b04;
  background: var(--coral);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(255, 200, 187, 0.4),
    0 0 24px rgba(255, 117, 89, 0.28);
  animation: triggerMine 0.45s ease both;
}

.cell.is-trigger .icon-mine .mine-core {
  fill: #2b0b04;
}

.cell.is-trigger .icon-mine .mine-glint {
  fill: rgba(255, 208, 196, 0.82);
}

.cell.is-wrong {
  color: var(--muted);
}

.cell .wrong-strike {
  position: absolute;
  inset: 18%;
  z-index: 2;
  pointer-events: none;
}

.cell .wrong-strike::before,
.cell .wrong-strike::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112%;
  height: 1.5px;
  border-radius: 2px;
  background: var(--coral);
  content: "";
}

.cell .wrong-strike::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.cell .wrong-strike::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* corner ticks */
.corner {
  position: absolute;
  z-index: 3;
  width: 13px;
  height: 13px;
  border-color: rgba(155, 232, 201, 0.38);
  border-style: solid;
  pointer-events: none;
}

.corner-tl {
  top: 6px;
  left: 6px;
  border-width: 1px 0 0 1px;
  border-radius: 3px 0 0;
}

.corner-tr {
  top: 6px;
  right: 6px;
  border-width: 1px 1px 0 0;
  border-radius: 0 3px 0 0;
}

.corner-bl {
  bottom: 6px;
  left: 6px;
  border-width: 0 0 1px 1px;
  border-radius: 0 0 0 3px;
}

.corner-br {
  right: 6px;
  bottom: 6px;
  border-width: 0 1px 1px 0;
  border-radius: 0 0 3px;
}

/* ---------- footer row ---------- */

.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  margin-top: 15px;
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.status-mark {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(155, 232, 201, 0.46);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status-tip {
  padding-left: 9px;
  border-left: 1px solid var(--line);
  color: var(--dim);
  font-size: 10px;
  white-space: nowrap;
}

.game-card.is-lost .status-mark {
  background: var(--coral);
  box-shadow: 0 0 8px rgba(255, 117, 89, 0.5);
}

.game-card.is-won .status-mark {
  background: var(--mint);
  box-shadow: 0 0 10px rgba(155, 232, 201, 0.75);
}

.game-card.is-lost .status {
  color: var(--coral-soft);
}

.game-card.is-won .status {
  color: var(--mint);
}

.flag-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.flag-toggle:hover {
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

.flag-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flag-toggle kbd {
  margin-left: 2px;
}

.flag-toggle[aria-pressed="true"] {
  border-color: rgba(255, 117, 89, 0.42);
  color: var(--coral-soft);
  background: rgba(255, 117, 89, 0.08);
}

.flag-toggle[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 5px rgba(255, 117, 89, 0.35));
}

.scroll-hint {
  margin: 11px 0 -3px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.13em;
  text-align: center;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid rgba(174, 208, 197, 0.16);
  border-radius: 4px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: cardIn 0.7s 0.14s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.side-panel {
  padding: 21px 21px 19px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(16, 32, 37, 0.82), rgba(8, 18, 22, 0.88));
  box-shadow:
    0 20px 45px -34px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.panel-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(174, 208, 197, 0.09);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.side-panel h2 {
  margin: 16px 0 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.records {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.records li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px dashed rgba(174, 208, 197, 0.09);
}

.records li:last-child {
  border-bottom: 0;
}

.records li > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 11.5px;
}

.records li i {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  font-style: normal;
}

.records strong {
  color: var(--mint);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.records strong.is-fresh {
  animation: recordFlash 0.8s ease;
}

.panel-note {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.7;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 10.5px;
}

.guide-key {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 6px;
  border: 1px solid rgba(174, 208, 197, 0.14);
  border-radius: 5px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.018);
}

.guide-panel > p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.keyline {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(174, 208, 197, 0.09);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.keyline > span {
  margin-right: auto;
  letter-spacing: 0.12em;
}

.has-touch .keyline {
  display: none;
}

.keyline kbd:first-of-type {
  min-width: 40px;
}

.side-signature {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.side-signature i {
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- footer ---------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding: 0 3px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.footer-divider {
  margin: 0 6px;
  color: rgba(155, 232, 201, 0.35);
}

.footer-motto {
  color: rgba(90, 111, 107, 0.72);
}

/* ---------- dialog ---------- */

.custom-dialog {
  width: min(470px, calc(100vw - 28px));
  max-width: none;
  padding: 0;
  overflow: visible;
  border: 1px solid rgba(174, 208, 197, 0.2);
  border-radius: 22px;
  color: var(--ink);
  background:
    radial-gradient(100% 70% at 90% -10%, rgba(74, 142, 124, 0.14), transparent 58%),
    #0c1b20;
  box-shadow:
    0 50px 120px -30px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.custom-dialog[open] {
  animation: dialogIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.custom-dialog::backdrop {
  background: rgba(2, 8, 10, 0.74);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.custom-dialog form {
  padding: 25px 26px 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head .eyebrow {
  margin-bottom: 6px;
  color: var(--mint);
}

.dialog-head h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.dialog-close {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.dialog-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.dialog-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 23px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.field small {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0;
}

.field small b {
  font-weight: 500;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid rgba(174, 208, 197, 0.16);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(4, 12, 15, 0.65);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus {
  border-color: rgba(155, 232, 201, 0.6);
  box-shadow: 0 0 0 3px rgba(155, 232, 201, 0.06);
}

.field input.is-invalid {
  border-color: rgba(255, 117, 89, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 117, 89, 0.07);
}

.dialog-note {
  margin: 15px 0 0;
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.7;
}

.form-error {
  min-height: 16px;
  margin: 7px 0 0;
  color: var(--coral-soft);
  font-size: 10.5px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 12px;
}

.button-ghost,
.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 42px;
  padding: 0 17px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.button-ghost {
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.button-ghost:hover {
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

.button-primary {
  border: 1px solid var(--coral);
  color: #2a0e07;
  background: var(--coral);
}

.button-primary:hover {
  border-color: #ff927b;
  background: #ff8b72;
}

.button-primary:active,
.button-ghost:active {
  transform: scale(0.98);
}

.button-primary svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- toast / confetti ---------- */

.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  z-index: 120;
  padding: 8px 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  color: #0c1719;
  background: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 110;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- game states ---------- */

.game-card.is-lost .board-shell {
  border-color: rgba(255, 117, 89, 0.26);
  animation: boardShake 0.36s ease both;
}

.game-card.is-won .board-shell {
  border-color: rgba(155, 232, 201, 0.3);
  animation: boardWin 0.9s ease both;
}

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .app {
    padding: 24px 24px 22px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr) 264px;
    gap: 18px;
  }

  .game-card {
    padding: 26px 26px 22px;
  }

  .level {
    gap: 8px;
    padding: 10px;
  }

  .level-index {
    display: none;
  }

  .side-panel {
    padding: 18px 18px 17px;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
  }

  .side-signature {
    display: none;
  }

  .records li {
    padding: 10px 0;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 16px 12px 20px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .brand-mark svg {
    width: 22px;
    height: 22px;
  }

  .brand-copy strong {
    font-size: 11px;
  }

  .brand-copy small {
    font-size: 8.5px;
    letter-spacing: 0.28em;
  }

  .site-code {
    display: none;
  }

  .sound-label {
    display: none;
  }

  .sound-toggle {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .layout {
    margin-top: 18px;
  }

  .game-card {
    padding: 20px 12px 16px;
    border-radius: 20px;
  }

  .game-card::before {
    left: 14%;
    width: 55%;
  }

  .game-heading {
    gap: 12px;
    margin-bottom: 17px;
  }

  .eyebrow {
    margin-bottom: 7px;
    font-size: 7.5px;
    letter-spacing: 0.14em;
  }

  h1 {
    font-size: clamp(28px, 8.5vw, 38px);
  }

  .best-badge {
    min-width: 76px;
    padding-left: 12px;
  }

  .best-badge span {
    font-size: 6.5px;
    letter-spacing: 0.12em;
  }

  .best-badge strong {
    font-size: 14px;
  }

  .levels {
    gap: 3px;
    padding: 3px;
    border-radius: 12px;
  }

  .level {
    justify-content: center;
    padding: 9px 4px;
    text-align: center;
    border-radius: 9px;
  }

  .level-copy {
    align-items: center;
    gap: 2px;
  }

  .level-copy strong {
    font-size: 11.5px;
  }

  .level-copy small {
    max-width: 100%;
    font-size: 7px;
  }

  .hud {
    gap: 12px;
    margin: 15px 1px 11px;
  }

  .readout {
    gap: 8px;
  }

  .readout-icon {
    width: 21px;
    height: 21px;
  }

  .readout-copy span {
    font-size: 7px;
    letter-spacing: 0.08em;
  }

  .readout-copy strong {
    font-size: 20px;
  }

  .reset-button {
    width: 45px;
    height: 45px;
  }

  .reset-button .face {
    width: 31px;
    height: 31px;
  }

  .reset-ring {
    inset: -4px;
  }

  .board-shell {
    border-radius: 13px;
  }

  .board-scroller {
    padding: 7px;
  }

  .corner {
    display: none;
  }

  .game-foot {
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
  }

  .status {
    flex: 1 1 190px;
    gap: 7px;
    font-size: 10.5px;
  }

  .status-tip {
    display: none;
  }

  .flag-toggle {
    height: 34px;
    padding: 0 9px;
  }

  .flag-toggle kbd {
    display: none;
  }

  .scroll-hint {
    margin-top: 9px;
    color: rgba(155, 232, 201, 0.62);
    font-size: 8.5px;
    letter-spacing: 0.09em;
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .side-panel {
    padding: 17px 17px 15px;
    border-radius: 15px;
  }

  .side-panel h2 {
    margin: 13px 0 8px;
    font-size: 15px;
  }

  .panel-label {
    padding-bottom: 8px;
  }

  .footer {
    margin-top: 18px;
    font-size: 7px;
    letter-spacing: 0.1em;
  }

  .custom-dialog form {
    padding: 21px 18px 19px;
  }

  .field-grid {
    gap: 7px;
    margin-top: 20px;
  }

  .field > span {
    display: block;
    font-size: 9px;
  }

  .field small {
    display: block;
    margin-top: 1px;
    font-size: 6.8px;
  }

  .field input {
    height: 42px;
    padding: 0 8px;
    font-size: 14px;
  }

  .dialog-head h2 {
    font-size: 23px;
  }

  .dialog-actions {
    margin-top: 8px;
  }

  .button-primary,
  .button-ghost {
    height: 41px;
  }
}

@media (max-width: 420px) {
  .app {
    padding-right: 10px;
    padding-left: 10px;
  }

  .level-copy small {
    display: none;
  }

  .level {
    padding: 10px 3px;
  }

  .level-copy strong {
    font-size: 11px;
  }

  .best-badge {
    min-width: 66px;
    padding-left: 10px;
  }

  .best-badge {
    min-width: 70px;
  }

  .game-heading {
    align-items: flex-end;
  }

  h1 {
    font-size: 28px;
  }

  .readout-icon {
    display: none;
  }

  .readout-time .readout-copy {
    align-items: flex-end;
  }

  .flag-toggle span {
    font-size: 9.5px;
  }

  .status {
    font-size: 9.5px;
  }

  .footer-motto {
    display: none;
  }
}

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

/* ---------- keyframes ---------- */

@keyframes revealDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 3px rgba(155, 232, 201, 0.08), 0 0 12px rgba(155, 232, 201, 0.55);
  }
  50% {
    opacity: 0.72;
    box-shadow: 0 0 0 4px rgba(155, 232, 201, 0.05), 0 0 18px rgba(155, 232, 201, 0.3);
  }
}

@keyframes cellOpen {
  from {
    transform: scale(0.86);
    opacity: 0.45;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes triggerMine {
  0% {
    transform: scale(0.9);
  }
  42% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes boardShake {
  0%,
  100% {
    transform: translateX(0);
  }
  22% {
    transform: translateX(-5px);
  }
  44% {
    transform: translateX(4px);
  }
  66% {
    transform: translateX(-3px);
  }
  82% {
    transform: translateX(2px);
  }
}

@keyframes boardWin {
  0% {
    box-shadow: inset 0 0 0 rgba(155, 232, 201, 0), inset 0 0 50px rgba(0, 0, 0, 0.22);
  }
  38% {
    box-shadow:
      inset 0 0 38px rgba(155, 232, 201, 0.08),
      0 0 34px rgba(155, 232, 201, 0.08);
  }
  100% {
    box-shadow: inset 0 0 0 rgba(155, 232, 201, 0), inset 0 0 50px rgba(0, 0, 0, 0.22);
  }
}

@keyframes recordFlash {
  0%,
  100% {
    color: var(--mint);
    text-shadow: 0 0 0 transparent;
  }
  35% {
    color: #eafff6;
    text-shadow: 0 0 16px rgba(155, 232, 201, 0.8);
  }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
