:root {
      --bg1: #0f172a;
      --bg2: #111827;
      --panel: rgba(31, 41, 55, 0.92);
      --panel-2: rgba(55, 65, 81, 0.95);
      --text: #f9fafb;
      --muted: #9ca3af;
      --accent: #fbbf24;
      --success: #10b981;
      --danger: #ef4444;
      --border: rgba(255,255,255,0.08);
      --shadow: 0 10px 30px rgba(0,0,0,0.30);
      --dark-good: #0b1220;
    }

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

    html, body {
      margin: 0;
      padding: 0;
    }

    body {
      font-family: Inter, Arial, sans-serif;
      color: var(--text);
      background: linear-gradient(180deg, var(--bg1), var(--bg2));
      min-height: 100vh;
      padding: 14px;
      padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px) + 108px);
      overflow-x: hidden;
    }

    .app {
      max-width: 1120px;
      margin: 0 auto;
    }

    .hero {
      text-align: center;
      margin-bottom: 14px;
    }

    h1 {
      margin: 0 0 6px;
      font-size: clamp(2rem, 6vw, 3rem);
      letter-spacing: 0.4px;
    }

    .subtitle {
      color: var(--muted);
      line-height: 1.45;
      max-width: 760px;
      margin: 0 auto;
      font-size: clamp(0.95rem, 2.7vw, 1.05rem);
    }

    .topbar {
      display: flex;
      gap: 10px;
      justify-content: center;
      align-items: center;
      flex-wrap: wrap;
      margin: 14px 0 16px;
    }

    .mode-switch {
      display: inline-flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: center;
    }

    .type-switch {
      display: inline-flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: center;
    }

    .config-panel {
      display: grid;
      gap: 10px;
      justify-items: center;
      margin: 0 0 16px;
      padding: 14px;
      border-radius: 16px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.08);
    }

    .config-panel[hidden] {
      display: none;
    }

    .config-row {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      width: 100%;
    }

    .seed-input {
      width: min(100%, 220px);
      border: 1px solid var(--border);
      background: var(--panel-2);
      color: var(--text);
      border-radius: 12px;
      padding: 12px 14px;
      font-size: 1rem;
      font-weight: 700;
      text-align: center;
      letter-spacing: 0.16em;
    }

    .seed-input::placeholder {
      letter-spacing: 0.06em;
      color: var(--muted);
    }

    .config-note {
      color: var(--muted);
      text-align: center;
      font-size: 0.92rem;
      line-height: 1.45;
    }

    .mode-btn {
      border: 1px solid var(--border);
      background: var(--panel-2);
      color: var(--text);
      border-radius: 999px;
      padding: 10px 14px;
      font-weight: 700;
      cursor: pointer;
    }

    .mode-btn.active {
      background: var(--accent);
      color: #111827;
      border-color: transparent;
    }

    .puzzle-meta {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 10px 14px;
      gap: 8px;
      padding: 10px 14px;
      border-radius: 14px;
      background: rgba(255,255,255,0.035);
      border: 1px dashed rgba(255,255,255,0.12);
      color: #d1d5db;
      font-weight: 600;
      font-size: 0.92rem;
      box-shadow: none;
      cursor: default;
    }

    .puzzle-meta::before {
      content: "ℹ";
      opacity: 0.75;
      font-size: 0.92rem;
    }

    .layout {
      display: grid;
      grid-template-columns: 1fr;
      gap: 16px;
      align-items: start;
    }

    .card {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 16px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      min-width: 0;
    }

    .section-title {
      margin: 0 0 12px;
      font-size: 1.08rem;
    }

    .board {
      display: grid;
      gap: 8px;
      align-items: end;
      width: 100%;
      margin: 0 auto 14px;
      padding-top: 8px;
    }

    .slot {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 7px;
      user-select: none;
      min-width: 0;
      transition: transform 300ms cubic-bezier(.22,1,.36,1), opacity 180ms ease;
      transform: translate(var(--move-x, 0px), var(--move-y, 0px)) scale(var(--move-scale, 1));
    }

    .slot.dragging {
      opacity: 0.72;
      z-index: 3;
    }
    .slot.drag-over .bottle {
      outline: 4px solid rgba(251, 191, 36, 0.95);
      outline-offset: 5px;
      filter: brightness(1.08);
    }

    .slot.changed .bottle {
      box-shadow:
        inset 0 8px 14px rgba(255,255,255,0.16),
        inset 0 -12px 16px rgba(0,0,0,0.24),
        0 8px 20px rgba(0,0,0,0.32),
        inset 0 -6px 0 rgba(96,165,250,0.92);
    }

    .slot.changed .slot-label {
      color: #bfdbfe;
      font-weight: 700;
    }

    .slot.swap-anim {
      --move-scale: 1.04;
    }

    .slot-label {
      font-size: 0.76rem;
      color: var(--muted);
      text-align: center;
      line-height: 1.1;
    }

    .bottle {
      width: min(100%, 72px);
      aspect-ratio: 0.52 / 1;
      position: relative;
      border: none;
      border-radius: 18px 18px 14px 14px;
      background: var(--color);
      box-shadow:
        inset 0 8px 14px rgba(255,255,255,0.16),
        inset 0 -12px 16px rgba(0,0,0,0.24),
        0 8px 20px rgba(0,0,0,0.32);
      cursor: pointer;
      transition: transform 0.18s ease, outline 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
      appearance: none;
      -webkit-appearance: none;
      touch-action: none;
    }

    .bottle:focus,
    .bottle:focus-visible {
      outline: none;
    }

    .bottle::before {
      content: "";
      position: absolute;
      top: -12%;
      left: 31%;
      width: 38%;
      height: 16%;
      background: #d1d5db;
      border-radius: 8px 8px 4px 4px;
      box-shadow: inset 0 2px 4px rgba(255,255,255,0.45);
    }

    .bottle::after {
      content: "";
      position: absolute;
      top: 12%;
      left: 15%;
      width: 18%;
      height: 45%;
      border-radius: 999px;
      background: rgba(255,255,255,0.25);
    }

    @media (hover: hover) and (pointer: fine) {
      .bottle:hover {
        transform: translateY(-4px);
        filter: brightness(1.03);
      }
    }

    .slot.selected .bottle {
      outline: 4px solid var(--accent);
      outline-offset: 4px;
      transform: translateY(-6px) scale(1.03);
    }

    .slot.locked .bottle {
      cursor: default;
      filter: saturate(0.55) brightness(0.85);
      box-shadow:
        inset 0 8px 14px rgba(255,255,255,0.1),
        inset 0 -12px 16px rgba(0,0,0,0.28),
        0 8px 20px rgba(0,0,0,0.24),
        0 0 0 4px rgba(255,255,255,0.06);
    }

    .slot.locked .slot-label {
      color: #fef3c7;
      font-weight: 700;
    }

    .slot.solved .slot-label {
      color: #d1fae5;
      font-weight: 700;
    }

    .slot.pointer-dragging {
      z-index: 6;
      pointer-events: none;
    }

    .slot.pointer-dragging .bottle {
      transform: translateY(-10px) scale(1.05);
      box-shadow:
        inset 0 8px 14px rgba(255,255,255,0.18),
        inset 0 -12px 16px rgba(0,0,0,0.24),
        0 18px 30px rgba(0,0,0,0.34);
    }

    .lock-toggle {
      width: 42px;
      height: 42px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.05);
      color: #e5e7eb;
      border-radius: 12px;
      padding: 0;
      cursor: pointer;
      transition: transform 0.08s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
      appearance: none;
      -webkit-appearance: none;
    }

    .lock-toggle:active {
      transform: scale(0.96);
    }

    .lock-toggle:hover {
      border-color: rgba(255,255,255,0.2);
      background: rgba(255,255,255,0.08);
    }

    .lock-toggle.locked {
      background: rgba(251, 191, 36, 0.14);
      border-color: rgba(251, 191, 36, 0.34);
      color: #fde68a;
    }

    .lock-icon {
      width: 18px;
      height: 18px;
      display: block;
      pointer-events: none;
      flex: 0 0 auto;
    }

    .help-box {
      margin-top: 18px;
      padding: 16px;
      border-radius: 16px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.08);
    }

    .help-box h3 {
      margin: 0 0 10px;
      font-size: 1rem;
    }

    .help-box p {
      margin: 0;
      color: #e5e7eb;
      line-height: 1.6;
    }

    .controls {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: center;
      margin-top: 10px;
    }

    .controls.hidden {
      display: none;
    }

    button.action {
      border: none;
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 0.96rem;
      font-weight: 700;
      cursor: pointer;
      transition: transform 0.08s ease, opacity 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
      appearance: none;
      -webkit-appearance: none;
    }

    button.action:hover {
      opacity: 0.97;
    }

    button.action:active {
      transform: scale(0.98);
    }

    button.action:disabled {
      opacity: 0.55;
      cursor: not-allowed;
    }

    .primary {
      background: var(--accent);
      color: #111827;
    }

    .secondary {
      background: var(--panel-2);
      color: var(--text);
    }

    .share-btn {
      background: var(--success);
      color: white;
    }

    .copy-btn {
      background: #2563eb;
      color: white;
    }

    .danger {
      background: var(--danger);
      color: white;
    }

    .status {
      margin-top: 14px;
      text-align: center;
      font-weight: 700;
      line-height: 1.4;
      display: grid;
      place-items: center;
      transition: transform 180ms ease, opacity 180ms ease;
    }

    .status:empty {
      display: none;
      margin-top: 0;
    }

    .result-status {
      min-height: 92px;
      margin-top: 12px;
    }

    .notice-status {
      margin-top: 12px;
    }

    .status.success {
      color: var(--success);
    }

    .status.info {
      color: #e5e7eb;
    }

    .notice-status.info {
      color: #d1d5db;
    }

    .notice-status.soft-error {
      color: #fcd34d;
    }

    .status-card {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: center;
      padding: 12px 16px;
      border-radius: 14px;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      box-shadow: 0 10px 22px rgba(0,0,0,0.16);
    }

    .result-status .status-card {
      width: min(100%, 560px);
      display: grid;
      gap: 8px;
      justify-items: center;
      text-align: center;
      padding: 16px 18px;
      border-radius: 18px;
      background: linear-gradient(135deg, rgba(59,130,246,0.24), rgba(59,130,246,0.14));
      border: 1px solid rgba(59,130,246,0.24);
      box-shadow: 0 16px 34px rgba(0,0,0,0.22), 0 0 0 1px rgba(255,255,255,0.03) inset;
    }

    .result-status.result-flash .status-card {
      animation: resultReveal 760ms cubic-bezier(.22,1,.36,1);
    }

    .result-status-title {
      font-size: 0.82rem;
      font-weight: 900;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #fde68a;
    }

    .result-status-body {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      font-size: clamp(1rem, 2.7vw, 1.16rem);
      color: #fff8dc;
    }

    .notice-status .status-card {
      padding: 10px 14px;
      border-radius: 12px;
      background: rgba(255,255,255,0.035);
      border: 1px solid rgba(255,255,255,0.06);
      box-shadow: 0 6px 16px rgba(0,0,0,0.12);
      font-size: 0.93rem;
      font-weight: 600;
    }

    .notice-status.soft-error .status-card {
      background: rgba(245, 158, 11, 0.10);
      border-color: rgba(245, 158, 11, 0.24);
      box-shadow: 0 6px 16px rgba(245, 158, 11, 0.08);
    }

    .status-pulse {
      animation: statusPulse 560ms ease;
    }

    .correct-count {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 2.2em;
      padding: 4px 10px;
      border-radius: 999px;
      background: linear-gradient(135deg, rgba(251,191,36,0.28), rgba(245,158,11,0.45));
      color: #fff7d1;
      border: 1px solid rgba(251,191,36,0.38);
      box-shadow: 0 0 0 4px rgba(251,191,36,0.08);
      font-size: 1.12em;
      font-weight: 900;
    }

    .small-note {
      margin-top: 8px;
      text-align: center;
      color: var(--muted);
      line-height: 1.45;
      font-size: 0.92rem;
    }

    .win-box {
      margin-top: 14px;
      text-align: center;
      padding: 18px;
      border-radius: 16px;
      background: rgba(16, 185, 129, 0.12);
      border: 1px solid rgba(16, 185, 129, 0.25);
    }

    .win-box strong {
      color: var(--success);
      display: block;
      margin-bottom: 6px;
      font-size: 1.15rem;
    }

    .share-wrap {
      display: flex;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 14px;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 14px;
    }

    .stat {
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.06);
      border-radius: 14px;
      padding: 12px;
      text-align: center;
    }

    .stat-value {
      font-size: 1.5rem;
      font-weight: 800;
      line-height: 1;
      margin-bottom: 6px;
    }

    .stat-label {
      font-size: 0.84rem;
      color: var(--muted);
    }

    .history-section {
      margin-top: 18px;
      border-top: 1px solid rgba(255,255,255,0.07);
      padding-top: 18px;
    }

    .history-wrap {
      max-height: 52vh;
      overflow: auto;
      padding-right: 4px;
    }

    .history {
      display: grid;
      gap: 10px;
    }

    .history-empty {
      color: var(--muted);
      line-height: 1.5;
      font-size: 0.95rem;
    }

    .history-item {
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.06);
      border-radius: 14px;
      padding: 12px;
      display: grid;
      gap: 10px;
    }

    .history-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 8px 12px;
      border-radius: 999px;
      background: var(--dark-good);
      border: 1px solid rgba(255,255,255,0.08);
      font-weight: 700;
      white-space: nowrap;
      font-size: 0.9rem;
    }

    .attempt-label {
      color: var(--muted);
      font-size: 0.92rem;
      font-weight: 600;
    }

    .history-row {
      display: flex;
      gap: 7px;
      flex-wrap: wrap;
    }

    .mini-wrap {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 5px;
      width: 34px;
    }

    .mini {
      width: 22px;
      height: 40px;
      border-radius: 8px 8px 6px 6px;
      background: var(--color);
      position: relative;
      box-shadow:
        inset 0 4px 8px rgba(255,255,255,0.12),
        inset 0 -6px 10px rgba(0,0,0,0.2);
    }

    .mini::before {
      content: "";
      position: absolute;
      top: -6px;
      left: 7px;
      width: 8px;
      height: 8px;
      border-radius: 3px 3px 2px 2px;
      background: #d1d5db;
    }

    .mini-index {
      font-size: 0.74rem;
      color: var(--muted);
    }



    .share-preview {
      margin-top: 12px;
      padding: 12px;
      border-radius: 12px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.06);
      white-space: pre-wrap;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.9rem;
      line-height: 1.4;
      color: #e5e7eb;
    }

    .celebrate .bottle {
      animation: solvedBounce 700ms ease;
    }

    .stair-celebrate .slot {
      animation: staircaseWave 760ms cubic-bezier(.22,1,.36,1);
      animation-delay: calc(var(--stair-index, 0) * 85ms);
      will-change: transform;
    }

    .stair-celebrate .slot .bottle {
      animation: staircaseBottleGlow 760ms cubic-bezier(.22,1,.36,1);
      animation-delay: calc(var(--stair-index, 0) * 85ms);
      will-change: transform, box-shadow, filter;
    }

    .guess-press {
      animation: guessPress 700ms cubic-bezier(0.2, 0.9, 0.25, 1);
    }

    .board-guessing {
      animation: boardGuessFlash 720ms cubic-bezier(0.2, 0.9, 0.25, 1);
    }

    .board-guessing .bottle {
      animation: bottleGuessPop 720ms cubic-bezier(0.2, 0.9, 0.25, 1);
    }

    .confetti {
      position: fixed;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 50;
    }

    .confetti-piece {
      position: absolute;
      top: -20px;
      width: 10px;
      height: 14px;
      opacity: 0.95;
      animation: confettiFall linear forwards;
    }

    @keyframes confettiFall {
      0% {
        transform: translate3d(0, -10vh, 0) rotate(0deg);
        opacity: 1;
      }
      100% {
        transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin));
        opacity: 0.95;
      }
    }

    @keyframes solvedBounce {
      0% { transform: translateY(0) scale(1); }
      20% { transform: translateY(-14px) scale(1.05); }
      40% { transform: translateY(0) scale(1); }
      60% { transform: translateY(-9px) scale(1.03); }
      100% { transform: translateY(0) scale(1); }
    }

    @keyframes guessPress {
      0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251,191,36,0), 0 0 0 rgba(0,0,0,0); filter: brightness(1); }
      14% { transform: scale(0.94); }
      42% { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(251,191,36,0.22), 0 12px 28px rgba(251,191,36,0.22); filter: brightness(1.06); }
      68% { transform: scale(0.99); box-shadow: 0 0 0 22px rgba(251,191,36,0.10), 0 8px 20px rgba(251,191,36,0.16); }
      100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251,191,36,0), 0 0 0 rgba(0,0,0,0); filter: brightness(1); }
    }

    @keyframes boardGuessFlash {
      0% { transform: scale(1); filter: brightness(1); }
      20% { transform: scale(0.992); }
      45% { transform: scale(1.018); filter: brightness(1.08); }
      100% { transform: scale(1); filter: brightness(1); }
    }

    @keyframes bottleGuessPop {
      0% { transform: translateY(0) scale(1); }
      16% { transform: translateY(6px) scale(0.97); }
      38% { transform: translateY(-12px) scale(1.05); }
      55% { transform: translateY(-6px) scale(1.02); }
      100% { transform: translateY(0) scale(1); }
    }

    @keyframes statusPulse {
      0% { transform: scale(0.98); opacity: 0.85; }
      50% { transform: scale(1.02); opacity: 1; }
      100% { transform: scale(1); opacity: 1; }
    }

    @keyframes resultReveal {
      0% { transform: translateY(8px) scale(0.97); opacity: 0.2; filter: brightness(0.92); }
      42% { transform: translateY(-4px) scale(1.03); opacity: 1; filter: brightness(1.08); }
      100% { transform: translateY(0) scale(1); opacity: 1; filter: brightness(1); }
    }

    @keyframes staircaseWave {
      0% { transform: translateY(0) scale(1); }
      18% { transform: translateY(6px) scale(0.985); }
      52% { transform: translateY(calc(var(--stair-lift, -24px) - 2px)) scale(1.04); }
      72% { transform: translateY(calc(var(--stair-lift, -24px) * 0.38)) scale(1.015); }
      100% { transform: translateY(0) scale(1); }
    }

    @keyframes staircaseBottleGlow {
      0% {
        transform: translateY(0) scale(1);
        filter: brightness(1);
        box-shadow:
          inset 0 8px 14px rgba(255,255,255,0.16),
          inset 0 -12px 16px rgba(0,0,0,0.24),
          0 8px 20px rgba(0,0,0,0.32);
      }
      52% {
        transform: translateY(-2px) scale(1.035);
        filter: brightness(1.12);
        box-shadow:
          inset 0 10px 16px rgba(255,255,255,0.24),
          inset 0 -12px 16px rgba(0,0,0,0.24),
          0 0 0 6px rgba(251,191,36,0.14),
          0 18px 30px rgba(0,0,0,0.34);
      }
      100% {
        transform: translateY(0) scale(1);
        filter: brightness(1);
        box-shadow:
          inset 0 8px 14px rgba(255,255,255,0.16),
          inset 0 -12px 16px rgba(0,0,0,0.24),
          0 8px 20px rgba(0,0,0,0.32);
      }
    }

    
    .bottom-ad-shell {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 40;
      padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
      pointer-events: none;
    }

    .bottom-ad-card {
      max-width: 1120px;
      margin: 0 auto;
      padding: 0;
      background: transparent;
      border: 0;
      border-radius: 0;
      box-shadow: none;
      backdrop-filter: none;
      pointer-events: auto;
    }

    .bottom-banner-ad {
      min-height: 50px;
      width: 100%;
      overflow: hidden;
      background: transparent;
    }

    .site-footer {
      margin-top: 18px;
      padding: 18px 0 8px;
      text-align: center;
      color: var(--muted);
    }

    .footer-card {
      background: rgba(255,255,255,0.035);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 16px;
      padding: 16px;
      box-shadow: var(--shadow);
    }

    .footer-links {
      display: flex;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }

    .footer-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 220px;
      text-decoration: none;
    }

    .footer-link {
      color: var(--accent);
      text-decoration: underline;
      font-weight: 600;
    }

    .footer-link:hover {
      color: #facc15;
      opacity: 1;
    }

    .footer-copy {
      font-size: 0.9rem;
      line-height: 1.5;
    }


    .action.copied-feedback {
      animation: copyFeedbackPulse 1s ease;
    }

    @keyframes copyFeedbackPulse {
      0% {
        transform: scale(1);
        box-shadow: var(--shadow);
      }
      30% {
        transform: scale(1.06);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.22), 0 12px 26px rgba(0,0,0,0.28);
      }
      100% {
        transform: scale(1);
        box-shadow: var(--shadow);
      }
    }

    .legal-page {
      max-width: 900px;
      margin: 0 auto;
    }

    .legal-page .card p,
    .legal-page .card li {
      color: #e5e7eb;
      line-height: 1.65;
    }

    .legal-page .card ul {
      padding-left: 1.2rem;
    }
@media (max-width: 920px) {
      .history-wrap {
        max-height: none;
      }
    }
    .mode-switch::-webkit-scrollbar {
      display: none;
    }
    .mode-switch {
      -ms-overflow-style: none;
      scrollbar-width: none;
    }

    @media (max-width: 640px) {
      .mode-switch {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 4px;
        gap: 6px;
      }

      .mode-btn {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
      }
    }

    @media (max-width: 430px) {
      .stat-value {
        font-size: 1.3rem;
      }

      .slot-label {
        font-size: 0.66rem;
      }

      .board {
        gap: 5px;
      }
    }


.custom-stats-section {
  margin-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 18px;
}

.custom-stats-section[hidden] {
  display: none;
}



    @media (min-width: 980px) {
      .layout {
        grid-template-columns: 1fr;
      }

      .history-wrap {
        max-height: 68vh;
      }
    }

    @media (max-width: 640px) {
      body {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px) + 92px);
      }

      .bottom-ad-shell {
        padding-left: 8px;
        padding-right: 8px;
      }

      .bottom-ad-card {
        padding: 0;
      }

      .bottom-banner-ad {
        min-height: 50px;
      }
    }


/* Mobile tap fix: avoid fixed ad overlay blocking controls on iPhone */
.app, .site-footer {
  position: relative;
  z-index: 2;
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .bottom-ad-shell {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 1;
    padding: 12px 0 0;
    pointer-events: none;
  }

  .bottom-ad-card {
    max-width: 100%;
  }
}
