:root {
        --font-display: 'Fraunces', serif;
        --font-ui: 'Space Grotesk', sans-serif;
        --font-num: 'JetBrains Mono', monospace;
      }

      :root[data-theme="dark"] {
        --bg-grad-a: #103a40;
        --bg-grad-b: #071e21;
        --glass: rgba(18, 59, 65, 0.55);
        --glass-strong: rgba(27, 75, 82, 0.65);
        --glass-border: rgba(242, 166, 90, 0.18);
        --glass-border-soft: rgba(111, 168, 173, 0.14);
        --cell-bg: rgba(255, 255, 255, 0.04);
        --amber: #F2A65A;
        --amber-hot: #FFD166;
        --cream: #F7F3E8;
        --muted: #9FC6C9;
        --danger: #E9724C;
        --overlay-bg: rgba(7, 30, 33, 0.72);
      }

      :root[data-theme="light"] {
        --bg-grad-a: #FCEFE0;
        --bg-grad-b: #F4DCC0;
        --glass: rgba(255, 255, 255, 0.55);
        --glass-strong: rgba(255, 255, 255, 0.72);
        --glass-border: rgba(180, 110, 40, 0.18);
        --glass-border-soft: rgba(120, 90, 50, 0.12);
        --cell-bg: rgba(90, 50, 10, 0.05);
        --amber: #C97A2B;
        --amber-hot: #A85E1B;
        --cream: #2C231B;
        --muted: #7A6650;
        --danger: #C1442A;
        --overlay-bg: rgba(252, 239, 224, 0.82);
      }

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

      html,
      body {
        margin: 0;
        min-height: 100%;
        background: radial-gradient(ellipse at top, var(--bg-grad-a) 0%, var(--bg-grad-b) 100%);
        color: var(--cream);
        font-family: var(--font-ui);
        overflow-x: hidden;
        transition: background 0.3s ease, color 0.3s ease;
      }

      body {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
      }

      a {
        color: inherit;
      }

      /* ---------- site header / footer ---------- */
      .site-header {
        display: flex;
        justify-content: center;
        padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
        background: var(--glass);
        backdrop-filter: blur(18px) saturate(160%);
        -webkit-backdrop-filter: blur(18px) saturate(160%);
        border-bottom: 1px solid var(--glass-border);
      }

      .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
      }

      .site-header .logo {
        display: flex;
        align-items: center;
        gap: 8px;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 1.6rem;
        text-decoration: none;
      }

      .site-header .logo-badge {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: linear-gradient(160deg, var(--amber-hot), var(--amber));
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: var(--font-num);
        font-weight: 800;
        font-size: 1.1rem;
        color: #10262a;
        flex-shrink: 0;
      }

      .site-header .logo .accent {
        color: var(--amber-hot);
      }

      .site-header .domain {
        font-family: var(--font-num);
        font-size: 0.68rem;
        letter-spacing: 1px;
        color: var(--muted);
        display: none;
      }

      @media (min-width: 480px) {
        .site-header .domain {
          display: inline;
        }
      }

      .icon-btn {
        background: var(--glass-strong);
        border: 1px solid var(--glass-border);
        color: var(--cream);
        width: 40px;
        height: 40px;
        border-radius: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.05rem;
        cursor: pointer;
        transition: transform 0.12s ease, background 0.12s ease;
      }

      .icon-btn:hover {
        transform: translateY(-1px);
      }

      .icon-btn:active {
        transform: translateY(0);
      }

      .icon-btn:focus-visible {
        outline: 2px solid var(--amber-hot);
        outline-offset: 2px;
      }

      .header-actions {
        display: flex;
        gap: 14px;
        align-items: center;
      }

      @media (min-width: 951px) {
        .header-inner {
          max-width: 950px;
        }
      }

      main {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px 16px;
      }

      .site-footer {
        padding: 18px max(20px, env(safe-area-inset-left)) max(22px, env(safe-area-inset-bottom));
        text-align: center;
        font-size: 0.72rem;
        color: var(--muted);
        background: var(--glass);
        backdrop-filter: blur(18px) saturate(160%);
        -webkit-backdrop-filter: blur(18px) saturate(160%);
        border-top: 1px solid var(--glass-border-soft);
      }

      .site-footer .footer-domain {
        color: var(--amber);
        font-family: var(--font-num);
      }

      .site-footer .footer-links {
        margin-top: 8px;
        display: flex;
        gap: 16px;
        justify-content: center;
        flex-wrap: wrap;
      }

      .site-footer .footer-links a {
        color: var(--muted);
        text-decoration: none;
      }

      .site-footer .footer-links a:hover {
        color: var(--amber-hot);
      }

      /* ---------- game card (glass) ---------- */
      .cabinet {
        width: min(94vw, 460px);
        padding: 24px 20px 28px;
        background: var(--glass);
        backdrop-filter: blur(22px) saturate(170%);
        -webkit-backdrop-filter: blur(22px) saturate(170%);
        border-radius: 24px;
        border: 1px solid var(--glass-border);
        box-shadow:
          0 30px 60px -25px rgba(0, 0, 0, 0.45),
          inset 0 1px 0 rgba(255, 255, 255, 0.08);
        position: relative;
      }

      .cabinet-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        margin-bottom: 18px;
        gap: 10px;
      }

      h1 {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 2.3rem;
        letter-spacing: 0.5px;
        margin: 0;
        line-height: 1;
      }

      h1 span {
        color: var(--amber-hot);
      }

      .subtitle {
        font-size: 0.68rem;
        letter-spacing: 2px;
        text-transform: uppercase;
        color: var(--muted);
        margin-top: 6px;
      }

      .scores {
        display: flex;
        gap: 8px;
      }

      .score-box {
        background: var(--glass-strong);
        border-radius: 5px;
        padding: 7px 12px;
        text-align: center;
        min-width: 62px;
        border: 1px solid var(--glass-border-soft);
      }

      .score-box .label {
        font-size: 0.58rem;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        color: var(--muted);
      }

      .score-box .value {
        font-family: var(--font-num);
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--amber-hot);
      }

      .controls-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 14px;
        gap: 8px;
      }

      .hint {
        font-size: 0.72rem;
        color: var(--muted);
      }

      .row-actions {
        display: flex;
        gap: 8px;
      }

      button.pill {
        font-family: var(--font-ui);
        font-weight: 600;
        font-size: 0.78rem;
        background: var(--amber);
        color: #10262a;
        border: none;
        padding: 8px 14px;
        border-radius: 5px;
        cursor: pointer;
        transition: transform 0.12s ease, background 0.12s ease;
      }

      :root[data-theme="light"] button.pill {
        color: #FCEFE0;
      }

      button.pill:hover {
        background: var(--amber-hot);
        transform: translateY(-1px);
      }

      button.pill:active {
        transform: translateY(0);
      }

      button.pill:focus-visible {
        outline: 2px solid var(--cream);
        outline-offset: 2px;
      }

      button.pill.ghost {
        background: rgb(9 78 28 / 93%);
        color: var(--cream);
        border: 1px solid var(--glass-border-soft);
      }

      .board-wrap {
        position: relative;
        touch-action: none;
      }

      .board {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, 1fr);
        gap: 10px;
        background: var(--cell-bg);
        padding: 10px;
        border-radius: 16px;
        aspect-ratio: 1 / 1;
        box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.15);
      }

      .cell-bg {
        background: rgb(76 8 8 / 8%);
        border-radius: 8px;
      }

      .tiles-layer {
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
      }

      .tile {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        font-family: var(--font-num);
        font-weight: 700;
        transition: top 0.13s ease, left 0.13s ease, transform 0.13s ease, opacity 0.13s ease;
        user-select: none;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
      }

      .tile.spawn {
        animation: pop 0.16s ease;
      }

      .tile.merged {
        animation: merge-pulse 0.18s ease;
      }

      .tile.leaving {
        opacity: 0;
        transform: scale(0.9);
      }

      @keyframes pop {
        0% {
          transform: scale(0.55);
          opacity: 0.4;
        }

        100% {
          transform: scale(1);
          opacity: 1;
        }
      }

      @keyframes merge-pulse {
        0% {
          transform: scale(1);
        }

        40% {
          transform: scale(1.16);
        }

        100% {
          transform: scale(1);
        }
      }

      .overlay {
        position: absolute;
        inset: 0;
        background: var(--overlay-bg);
        border-radius: 16px;
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        text-align: center;
        backdrop-filter: blur(6px);
        padding: 20px;
      }

      .overlay.show {
        display: flex;
      }

      .overlay .msg {
        font-family: var(--font-display);
        font-size: 1.6rem;
        font-weight: 700;
      }

      .overlay .msg.win {
        color: var(--amber-hot);
      }

      .overlay .msg.lose {
        color: var(--danger);
      }

      .overlay .final-score {
        font-family: var(--font-num);
        color: var(--muted);
        font-size: 0.85rem;
      }

      .name-row {
        display: flex;
        gap: 8px;
        margin-top: 4px;
      }

      .name-row input {
        font-family: var(--font-ui);
        background: var(--glass-strong);
        border: 1px solid var(--glass-border-soft);
        color: var(--cream);
        border-radius: 10px;
        padding: 8px 10px;
        width: 130px;
        font-size: 0.82rem;
      }

      .name-row input:focus-visible {
        outline: 2px solid var(--amber-hot);
      }

      .overlay-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 6px;
      }

      footer.instructions {
        margin-top: 14px;
        font-size: 0.7rem;
        color: var(--muted);
        text-align: center;
        line-height: 1.5;
      }

      /* ---------- leaderboard modal ---------- */
      .modal-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 50;
        padding: 20px;
      }

      .modal-backdrop.show {
        display: flex;
      }

      .modal {
        width: min(92vw, 380px);
        max-height: 80vh;
        overflow-y: auto;
        background: var(--glass-strong);
        backdrop-filter: blur(24px) saturate(180%);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        border: 1px solid var(--glass-border);
        border-radius: 18px;
        padding: 20px;
      }

      .modal h2 {
        font-family: var(--font-display);
        margin: 0 0 12px;
        font-size: 1.3rem;
      }

      .modal ol {
        list-style: none;
        margin: 0;
        padding: 0;
      }

      .modal li {
        display: flex;
        justify-content: space-between;
        padding: 8px 4px;
        border-bottom: 1px solid var(--glass-border-soft);
        font-size: 0.88rem;
      }

      .modal li:last-child {
        border-bottom: none;
      }

      .modal li .rank {
        color: var(--muted);
        width: 24px;
      }

      .modal li .name {
        flex: 1;
      }

      .modal li .pts {
        font-family: var(--font-num);
        color: var(--amber-hot);
        font-weight: 700;
      }

      .modal .empty {
        color: var(--muted);
        font-size: 0.85rem;
        text-align: center;
        padding: 12px 0;
      }

      .modal-close {
        margin-top: 14px;
        width: 100%;
      }

      /* ---------- toast ---------- */
      .toast {
        position: fixed;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        background: var(--glass-strong);
        border: 1px solid var(--glass-border);
        color: var(--cream);
        padding: 10px 18px;
        border-radius: 12px;
        font-size: 0.82rem;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s ease;
        z-index: 60;
        backdrop-filter: blur(16px);
      }

      .toast.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
      }

      /* fullscreen mobile experience */
      :fullscreen main {
        padding: 12px;
      }

      :fullscreen .site-header,
      :fullscreen .site-footer {
        display: none;
      }

      @media (max-width: 420px) {
        .cabinet {
          width: 100%;
          border-radius: 18px;
          padding: 18px 14px 22px;
        }

        h1 {
          font-size: 1.9rem;
        }
      }

      @media (prefers-reduced-motion: reduce) {

        .tile,
        .tile-inner {
          animation: none !important;
          transition: none !important;
        }
      }

      /* ---------- info / SEO content section ---------- */
      .info-section {
        padding: 8px 16px 40px;
        display: flex;
        justify-content: center;
      }

      .info-inner {
        width: 100%;
        max-width: 700px;
      }

      .info-inner h2 {
        font-family: var(--font-display);
        font-size: 1.35rem;
        margin: 34px 0 10px;
      }

      .info-inner h2:first-child {
        margin-top: 0;
      }

      .info-inner p {
        font-size: 0.92rem;
        line-height: 1.65;
        color: var(--cream);
        margin: 0 0 8px;
      }

      .tips-list {
        margin: 0;
        padding-left: 20px;
        font-size: 0.92rem;
        line-height: 1.7;
      }

      .tips-list li {
        margin-bottom: 4px;
      }

      .faq details {
        background: var(--glass);
        border: 1px solid var(--glass-border-soft);
        border-radius: 12px;
        padding: 12px 16px;
        margin-bottom: 10px;
      }

      .faq summary {
        cursor: pointer;
        font-weight: 600;
        font-size: 0.94rem;
        list-style: none;
      }

      .faq summary::-webkit-details-marker {
        display: none;
      }

      .faq summary::before {
        content: "+";
        color: var(--amber-hot);
        display: inline-block;
        width: 16px;
        font-weight: 700;
      }

      .faq details[open] summary::before {
        content: "–";
      }

      .faq details p {
        margin: 10px 0 0;
        font-size: 0.88rem;
        color: var(--muted);
      }

      @media (min-width: 951px) {
        .info-inner {
          max-width: 950px;
        }
      }
      .container{
    max-width:950px;
    margin:0 auto;
    padding:20px 15px;
}

.how-to-play-img{
    width:100%;
    height:auto;
    display:block;
    margin:auto;
    border-radius:7px;
    border:2px solid rgba(255,255,255,.08);
    box-shadow:0 15px 40px rgba(0,0,0,.35);
    margin-bottom: -20px;
}