    @import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

    :root {
      --bg: #f7fbff;
      --panel: #ffffff;
      --grid-bg: #f0f8ff;
      --accent: #ff7a59;
      --accent-deep: #d95a3d;
      --ink: #15314b;
      --ink-soft: #45627b;
      --mint: #5ec4a8;
      --line: #b8d6ea;
      --safe-inline: max(env(safe-area-inset-left), env(safe-area-inset-right));
      --cell: 54px;
      --gap: 6px;
      --board-pad: 10px;
      --board-size: calc(var(--cell) * 7 + var(--gap) * 6 + var(--board-pad) * 2);
    }

    * { box-sizing: border-box; }

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

    body {
      margin: 0;
      font-family: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;
      background:
        radial-gradient(circle at 12% 12%, #daf1ff 0%, transparent 42%),
        radial-gradient(circle at 88% 90%, #e6fff6 0%, transparent 38%),
        var(--bg);
      min-height: 100dvh;
      display: grid;
      place-items: center;
      color: var(--ink);
      padding: 16px;
      padding-inline: calc(16px + var(--safe-inline));
    }

    .game {
      width: min(96vw, 640px);
      max-height: 100dvh;
      background: var(--panel);
      border: 2px solid #d7ebf8;
      border-radius: 22px;
      box-shadow:
        0 18px 44px rgba(38, 86, 120, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.8) inset;
      padding: 18px;
      overflow: hidden;
      margin-inline: auto;
    }

    .top {
      display: grid;
      grid-template-columns: 1fr auto;
      grid-template-areas:
        "title rounds"
        "score score"
        "meta meta";
      align-items: center;
      gap: 10px;
      margin-bottom: 14px;
      min-height: 44px;
    }

    .title {
      grid-area: title;
      font-family: "Fredoka", "Nunito", sans-serif;
      font-size: 30px;
      font-weight: 700;
      letter-spacing: 0.2px;
      color: #1f4363;
      text-shadow: 0 1px 0 #ffffff;
    }

    .rounds-badge {
      grid-area: rounds;
      justify-self: end;
      background: linear-gradient(180deg, #fff5e8 0%, #ffe4bf 100%);
      border: 2px solid #f0b772;
      color: #8b4c1e;
      border-radius: 999px;
      padding: 6px 12px;
      font-weight: 800;
      font-size: 15px;
      box-shadow: 0 6px 14px rgba(230, 141, 47, 0.25);
      white-space: nowrap;
    }

    .score-card {
      grid-area: score;
      display: grid;
      grid-template-columns: auto 1fr;
      align-items: center;
      gap: 10px;
      background: linear-gradient(180deg, #f1fbff 0%, #dff4ff 100%);
      border: 2px solid #b7ddf2;
      border-radius: 14px;
      padding: 9px 12px;
      box-shadow:
        0 8px 16px rgba(61, 129, 172, 0.16),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    }

    .score-label {
      color: #3f647f;
      font-weight: 800;
      font-size: 14px;
    }

    .score-value {
      justify-self: end;
      font-family: "Fredoka", "Nunito", sans-serif;
      font-size: 30px;
      line-height: 1;
      color: #1f6b95;
      text-shadow: 0 1px 0 #fff;
    }

.stats {
  grid-area: meta;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 14px;
      color: var(--ink-soft);
      width: 100%;
      line-height: 1.2;
    }

    .stats span {
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      background: #eef7ff;
      border: 1px solid #cfe4f4;
      border-radius: 999px;
      padding: 5px 10px;
      text-align: center;
      font-weight: 700;
    }

    .board-wrap {
      width: var(--board-size);
      max-width: 100%;
      margin-inline: auto;
      background: var(--grid-bg);
      border: 2px solid var(--line);
      border-radius: 16px;
      padding: var(--board-pad);
      position: relative;
      overflow: hidden;
      box-shadow:
        0 10px 22px rgba(71, 128, 169, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.75) inset;
    }

    .board-shell {
      width: calc(var(--cell) * 7 + var(--gap) * 6);
      height: calc(var(--cell) * 7 + var(--gap) * 6);
      max-width: 100%;
      margin: 0 auto;
      position: relative;
    }

    .grid-hit {
      position: absolute;
      inset: 0;
      display: grid;
      grid-template-columns: repeat(7, var(--cell));
      grid-auto-rows: var(--cell);
      gap: var(--gap);
      touch-action: none;
      user-select: none;
      z-index: 3;
    }

    .hit-cell {
      border-radius: 14px;
      border: 1px solid #c5def0;
      background: transparent;
      cursor: pointer;
      position: relative;
      transition: background-color 0.12s ease, box-shadow 0.12s ease;
    }

    .hit-cell.selected {
      background: rgba(255, 122, 89, 0.17);
      box-shadow: inset 0 0 0 2px rgba(255, 122, 89, 0.64);
    }

    .hit-cell.start {
      background: radial-gradient(circle at 50% 50%, rgba(94, 196, 168, 0.26) 0%, rgba(94, 196, 168, 0.12) 62%, rgba(94, 196, 168, 0.06) 100%);
      box-shadow:
        inset 0 0 0 2px #2e9e7f,
        0 0 0 2px rgba(255, 255, 255, 0.8),
        0 0 18px rgba(46, 158, 127, 0.28);
    }

    .hit-cell.start::before {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: clamp(16px, calc(var(--cell) * 0.42), 24px);
      height: clamp(16px, calc(var(--cell) * 0.42), 24px);
      border-radius: 999px;
      background:
        radial-gradient(circle, #ffffff 0 22%, #2e9e7f 24% 44%, #c8fff0 46% 62%, #2e9e7f 64% 80%, transparent 82%);
      box-shadow:
        0 0 0 2px rgba(46, 158, 127, 0.3),
        0 6px 10px rgba(35, 87, 108, 0.22);
      animation: start-pulse 1.1s ease-in-out infinite;
      pointer-events: none;
    }

    .hit-cell.start::after {
      content: "";
      position: absolute;
      inset: 3px;
      border-radius: 12px;
      border: 2px dashed rgba(46, 158, 127, 0.52);
      animation: start-orbit 1.9s linear infinite;
      pointer-events: none;
    }

    @keyframes start-pulse {
      0% { transform: translate(-50%, -50%) scale(1); }
      50% { transform: translate(-50%, -50%) scale(1.08); }
      100% { transform: translate(-50%, -50%) scale(1); }
    }

    @keyframes start-orbit {
      0% { transform: rotate(0deg); opacity: 0.45; }
      50% { opacity: 0.75; }
      100% { transform: rotate(360deg); opacity: 0.45; }
    }

    .tiles-layer,
    .path-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .tiles-layer { z-index: 2; }
    .path-layer { z-index: 1; }

    .tile {
      width: var(--cell);
      height: var(--cell);
      border-radius: 14px;
      border: 1px solid #c9dff0;
      background: linear-gradient(180deg, #ffffff 0%, #eef8ff 100%);
      display: grid;
      place-items: center;
      font-size: clamp(18px, calc(var(--cell) * 0.58), 30px);
      line-height: 1;
      position: absolute;
      scale: 1;
      transform: translate(0, 0);
      will-change: transform, opacity, scale;
      box-shadow:
        0 4px 10px rgba(67, 115, 148, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.95) inset;
    }

    .tile.wild {
      border-color: #e4b42c;
      background:
        radial-gradient(circle at 30% 30%, #fff7c8 0%, #ffe78b 48%, #f7cd54 100%);
      box-shadow:
        0 0 0 1px rgba(228, 180, 44, 0.58),
        0 0 16px rgba(244, 191, 71, 0.72);
      animation: wild-glow 1.15s ease-in-out infinite;
    }

    .tile.wild.wild-born {
      animation:
        wild-pop 420ms ease-out 1,
        wild-glow 1.15s ease-in-out 420ms infinite;
    }

    @keyframes wild-glow {
      0% { filter: brightness(1); }
      50% { filter: brightness(1.18); }
      100% { filter: brightness(1); }
    }

    @keyframes wild-pop {
      0% { scale: 0.2; opacity: 0; }
      70% { scale: 1.18; opacity: 1; }
      100% { scale: 1; opacity: 1; }
    }

    .tile.clearing {
      animation: pop-fade 300ms ease forwards;
    }

    @keyframes pop-fade {
      0% { scale: 1; opacity: 1; }
      50% { scale: 1.18; opacity: 0.9; }
      100% { scale: 0.25; opacity: 0; }
    }

    .controls {
      margin-top: 14px;
      display: grid;
      gap: 10px;
    }

    .clear-row {
      display: grid;
      place-items: center;
    }

.clear-row .primary {
  width: min(100%, 360px);
  min-height: 46px;
}

    .minor-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    button {
      appearance: none;
      -webkit-appearance: none;
      border: none;
      border-radius: 12px;
      padding: 10px 14px;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
      background: linear-gradient(180deg, #ffffff 0%, #ecf6ff 100%);
      color: #2f4f69;
      border: 1px solid #c3dced;
      transition: filter 180ms ease, transform 180ms ease, box-shadow 180ms ease;
      box-shadow: 0 4px 10px rgba(66, 119, 157, 0.14);
    }

    button:hover {
      filter: brightness(1.02);
    }

    button:active {
      filter: brightness(0.98);
    }

    button.primary {
      background: linear-gradient(180deg, #ff8f72 0%, var(--accent) 100%);
      color: #fff;
      border-color: var(--accent-deep);
      box-shadow: 0 8px 16px rgba(255, 122, 89, 0.32);
    }

    button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .hint {
      margin-top: 10px;
      font-size: 13px;
      color: #5a758b;
      line-height: 1.45;
      background: #f3faff;
      border: 1px dashed #c4deef;
      border-radius: 12px;
      padding: 8px 10px;
    }

    .overlay {
      position: fixed;
      inset: 0;
      background: rgba(30, 57, 78, 0.38);
      display: grid;
      place-items: center;
      padding: 16px;
      z-index: 30;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }

    .overlay.show {
      opacity: 1;
      pointer-events: auto;
    }

    .result-modal {
      width: min(92vw, 440px);
      background: #ffffff;
      border: 2px solid #c7e1f1;
      border-radius: 16px;
      box-shadow:
        0 28px 60px rgba(30, 75, 108, 0.36),
        0 0 0 2px rgba(236, 247, 255, 0.95) inset;
      padding: 18px 16px;
      transform: translateY(8px) scale(0.98);
      transition: transform 0.2s ease;
    }

    .overlay.show .result-modal {
      transform: translateY(0) scale(1);
    }

    .result-title {
      font-size: 24px;
      font-family: "Fredoka", "Nunito", sans-serif;
      font-weight: 700;
      color: #234867;
      margin: 0 0 12px;
      text-align: center;
    }

    .result-list {
      margin: 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 8px;
      color: #44647d;
      font-size: 16px;
    }

    .result-list li {
      background: #f2f9ff;
      border: 1px solid #c5def0;
      border-radius: 10px;
      padding: 8px 10px;
    }

    button:focus-visible,
    .hit-cell:focus-visible {
      outline: 3px solid rgba(94, 196, 168, 0.58);
      outline-offset: 1px;
    }

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

    .result-actions {
      margin-top: 14px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    @media (max-width: 600px) {
      :root {
        --cell: min(calc((100vw - 96px - (var(--safe-inline) * 2)) / 7), calc((100dvh - 300px) / 7));
        --gap: 4px;
      }
      body {
        padding-block: 12px;
        padding-inline: calc(12px + var(--safe-inline));
      }
      .game {
        width: 100%;
        padding: 12px;
      }
      .board-wrap {
        padding: 6px;
      }
      .title { font-size: 18px; }
      .top { margin-bottom: 10px; }
      .rounds-badge {
        font-size: 13px;
        padding: 5px 10px;
      }
      .score-card {
        padding: 8px 10px;
      }
      .score-label {
        font-size: 12px;
      }
      .score-value {
        font-size: 24px;
      }
      .stats {
        font-size: 12px;
        gap: 6px;
        width: 100%;
      }
      .controls {
        margin-top: 10px;
        gap: 8px;
      }
      .minor-row {
        grid-template-columns: 1fr;
      }
      .controls button {
        min-height: 40px;
      }
      button {
        font-size: 14px;
        padding: 8px 10px;
      }
      .hint {
        font-size: 11px;
        margin-top: 8px;
        line-height: 1.35;
      }
    }
