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

:root {
    --bg-0: #070a14;
    --bg-1: #0b1020;
    --panel: #111a30;
    --panel-2: #0e1526;
    --line: rgba(120, 150, 220, 0.14);
    --cyan: #4ce9f5;
    --cyan-dim: rgba(76, 233, 245, 0.28);
    --cyan-glow: rgba(76, 233, 245, 0.55);
    --blue-a: #6ab6ff;
    --blue-b: #1a4fc4;
    --red-a: #ff8a8a;
    --red-b: #d31f3c;
    --gold: #ffd166;
    --text: #e8edf9;
    --muted: #7c88ad;
    --danger: #ff5470;
    --good: #57e39b;
    --radius: 18px;
    --font-display: 'Orbitron', 'Rajdhani', system-ui, sans-serif;
    --font-body: 'Rajdhani', system-ui, -apple-system, sans-serif;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(1200px 700px at 15% -10%, rgba(60, 90, 190, 0.18), transparent 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(76, 233, 245, 0.09), transparent 55%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, #060810 100%);
    color: var(--text);
    font-family: var(--font-body);
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

button {
    font-family: inherit;
    -webkit-user-select: none;
    user-select: none;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    margin: 0;
}

/* ---------------- Preloader ---------------- */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1000px 700px at 50% 30%, #0e1730 0%, #060810 70%);
    transition: opacity .6s ease, visibility .6s ease;
}

#preloader.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pl-logo {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 22px;
}

.pl-logo svg {
    width: 100%;
    height: 100%;
    display: block;
}

.pl-ring {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 5;
    stroke-linecap: round;
    filter: drop-shadow(0 0 8px var(--cyan-glow));
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: pl-draw 1.6s ease forwards, pl-spin 3.2s linear infinite;
    transform-origin: 50% 50%;
}

@keyframes pl-draw {
    to {
        stroke-dashoffset: 40;
    }
}

@keyframes pl-spin {
    to {
        transform: rotate(360deg);
    }
}

.pl-core {
    fill: url(#coreGrad);
    animation: pl-pulse 1.4s ease-in-out infinite;
    transform-origin: 50% 50%;
}

@keyframes pl-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: .9;
    }

    50% {
        transform: scale(1.14);
        opacity: 1;
    }
}

.pl-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 6px;
    background: linear-gradient(90deg, var(--cyan), #8fb8ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 30px rgba(76, 233, 245, 0.25);
    margin-bottom: 20px;
}

.pl-bar-track {
    width: 180px;
    height: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.pl-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--blue-b), var(--cyan));
    box-shadow: 0 0 12px var(--cyan-glow);
    transition: width .18s ease;
}

.pl-tip {
    margin-top: 12px;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--muted);
    min-height: 16px;
}

/* ---------------- App shell ---------------- */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity .5s ease;
}

#app.show {
    opacity: 1;
}

.screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

[hidden] {
    display: none !important;
}

/* ---------------- Menu screen ---------------- */
.menu-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px 40px;
    position: relative;
    padding-top: calc(32px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.menu-bg-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.pdot {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--cyan);
    opacity: .5;
    filter: drop-shadow(0 0 4px var(--cyan));
    animation: float-up linear infinite;
}

@keyframes float-up {
    from {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    10% {
        opacity: .6;
    }

    90% {
        opacity: .4;
    }

    to {
        transform: translateY(-110vh) translateX(20px);
        opacity: 0;
    }
}

.brand {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
}

.brand-title {
    font-size: clamp(28px, 8vw, 40px);
    font-weight: 800;
    letter-spacing: clamp(4px, 2vw, 10px);
    background: linear-gradient(90deg, #8fb8ff, var(--cyan) 55%, #8fb8ff);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: sheen 5s linear infinite;
    text-shadow: 0 0 40px rgba(76, 233, 245, 0.18);
}

@keyframes sheen {
    to {
        background-position: 200% center;
    }
}

.brand-sub {
    margin-top: 6px;
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--muted);
    text-transform: uppercase;
}

.menu-actions {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    border: none;
    cursor: pointer;
    border-radius: 30px;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    color: #04121c;
    background: linear-gradient(135deg, var(--cyan), #78d6ff);
    box-shadow:
        0 8px 24px rgba(76, 233, 245, 0.25),
        0 5px 0 rgba(16, 95, 120, 0.45),
        0 0 0 2px rgba(0, 35, 50, 0.25),
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        inset 0 -3px 4px rgba(0, 70, 90, 0.25),
        inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    margin-bottom: 2%;
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    box-shadow:
        0 5px 0 rgba(0, 0, 0, 0.35),
        0 10px 22px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -2px 4px rgba(0, 0, 0, 0.25),
        inset 0 0 0 1px var(--line);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
    font-size: 13px;
    padding: 8px;
}

.menu-footer-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 4px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 1px var(--line) inset;
    color: var(--text);
    transition: background .15s ease, transform .15s ease;
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------------- Game screen layout (no-scroll) ---------------- */
#screen-game {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---------------- Top bar (game) ---------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 8px;
    flex-shrink: 0;
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
}

.topbar-title {
    font-size: 15px;
    letter-spacing: 3px;
    font-weight: 700;
    color: var(--text);
}

.topbar-side {
    display: flex;
    gap: 6px;
}

/* ---------------- Game wrap ---------------- */
.game-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 12px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 5px;
    overflow: hidden;
    min-height: 0;
}

/* ---------------- Player panel ---------------- */
.player-panel {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border-radius: 14px;
    padding: 7px 12px;
    box-shadow: 0 0 0 1px var(--line), 0 8px 20px rgba(0, 0, 0, 0.35);
    transition: box-shadow .25s ease, transform .25s ease, opacity .25s ease;
    opacity: .55;
    transform: scale(0.97);
    flex-shrink: 0;
     /* 3D Border */
    border: 1px solid rgba(255,255,255,.12);

    /* 3D Shadow */
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.18),      /* top highlight */
        inset 0 -2px 0 rgba(0,0,0,.35),           /* bottom shadow */
        0 0 0 1px rgba(255,255,255,.06),          /* outer border */
        0 8px 18px rgba(0,0,0,.35),               /* main shadow */
        0 14px 30px rgba(0,0,0,.25);              /* depth */

    transition: all .25s ease;

    opacity: .55;
    transform: scale(.97);
    flex-shrink: 0;
}


.player-panel.active {
    opacity: 1;
    transform: scale(1);
}

.player-panel.active.turn-blue {
    box-shadow: 0 0 0 1.5px rgba(106, 182, 255, 0.7), 0 0 20px rgba(74, 144, 255, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
}

.player-panel.active.turn-red {
    box-shadow: 0 0 0 1.5px rgba(255, 90, 110, 0.7), 0 0 20px rgba(230, 60, 80, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
}

.player-panel.flipped {
    transform: rotate(180deg) scale(0.97);
}

.player-panel.flipped.active {
    transform: rotate(180deg) scale(1);
}

.pp-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.pp-id {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pp-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

#dotTop {
    background: var(--red-a);
    color: var(--red-a);
}

#dotBottom {
    background: var(--blue-a);
    color: var(--blue-a);
}

.pp-name {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
}

.pp-turn-tag {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--muted);
    text-transform: uppercase;
    opacity: 0;
    transition: opacity .2s ease;
}

.player-panel.active .pp-turn-tag {
    opacity: 1;
}

.pp-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 3px;
}

.wtool {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 1px var(--line) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: box-shadow .15s ease, background .15s ease, transform .1s ease;
}

.wtool:active {
    transform: scale(0.94);
}

.wtool.selected {
    background: rgba(76, 233, 245, 0.12);
    box-shadow: 0 0 0 1.5px var(--cyan), 0 0 12px var(--cyan-glow);
}

.wtool:disabled {
    opacity: .3;
    cursor: default;
}

.wtool .bar {
    background: linear-gradient(180deg, var(--cyan), #1fb9cc);
    box-shadow: 0 0 6px var(--cyan-glow);
    border-radius: 3px;
}

#panelTop .wtool .bar {
    background: linear-gradient(180deg, var(--red-a), var(--red-b));
    box-shadow: 0 0 6px rgba(255, 138, 138, 0.5);
}

#panelBottom .wtool .bar {
    background: linear-gradient(180deg, var(--blue-a), var(--blue-b));
    box-shadow: 0 0 6px rgba(106, 182, 255, 0.5);
}

#panelTop .wtool.selected {
    background: rgba(255, 90, 110, 0.12);
    box-shadow: 0 0 0 1.5px var(--red-a), 0 0 12px rgba(255, 138, 138, 0.4);
}

#panelBottom .wtool.selected {
    background: rgba(106, 182, 255, 0.12);
    box-shadow: 0 0 0 1.5px var(--blue-a), 0 0 12px rgba(106, 182, 255, 0.4);
}

.wtool.h .bar {
    width: 26px;
    height: 6px;
}

.wtool.v .bar {
    width: 6px;
    height: 26px;
}

.pp-count {
    text-align: center;
}

.pp-count-label {
    font-size: 12px;
    letter-spacing: 2px;
    color: #fff;
    text-transform: uppercase;
}

.pp-count-num {
    font-size: 22px;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--text);
    line-height: 1.1;
}

/* ---------------- Board ---------------- */
.board-frame {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    flex-shrink: 1;
    min-height: 0;
    border-radius: 16px;
    background: linear-gradient(180deg, #0d1428, #0a0f20);
    box-shadow: 0 0 0 1px var(--line), 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(0, 0, 0, 0.35);
    padding: 6px;
    position: relative;
}

#board {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    border-radius: 10px;
    margin: auto;
}

.status-line {
    min-height: 16px;
    font-size: 12px;
    letter-spacing: 1px;
    color: #fff;
    text-align: center;
    flex-shrink: 0;font-weight: bold;
}

.status-line.warn {
    color: var(--danger);
}

.status-line.good {
    color: var(--good);
}

/* ---------------- Modals ---------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(4, 6, 14, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-card {
    width: 100%;
    max-width: 380px;
    max-height: 82vh;
    overflow: auto;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 0 0 1px var(--line), 0 30px 60px rgba(0, 0, 0, 0.5);
    animation: modalPop .28s cubic-bezier(.2, .9, .3, 1.3);
}

@keyframes modalPop {
    from {
        transform: translateY(18px) scale(0.96);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 17px;
    letter-spacing: 2px;
    font-weight: 700;    color: #6fd9fd;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.rule-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.rule-ico {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(76, 233, 245, 0.1);
    box-shadow: 0 0 0 1px var(--cyan-dim) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan);
}

.rule-ico svg {
    width: 18px;
    height: 18px;
}

.rule-text b {
    color: var(--text);
}

.rule-text {
    font-size: 16px;
    line-height: 1.55;
    color: #c3cbe6;
}

.modal-cta {
    margin-top: 4px;
}

/* win modal */
#winCanvas {
    position: fixed;
    inset: 0;
    z-index: 59;
    pointer-events: none;
}

.win-card {
    text-align: center;
}

.win-title {
    font-size: 24px;
    letter-spacing: 3px;
    margin-bottom: 4px;
    text-shadow: 0 0 20px currentColor;
}

.win-sub {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 18px;
    letter-spacing: 1px;
}

.win-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hint-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.9), var(--good) 60%, transparent 75%);
    opacity: .85;
    pointer-events: none;
    animation: hint-pulse 1.3s ease-in-out infinite;
}

@keyframes hint-pulse {

    0%,
    100% {
        transform: scale(0.85);
        opacity: .55;
    }

    50% {
        transform: scale(1.1);
        opacity: .95;
    }
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 20, 38, 0.95);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 12px;
    letter-spacing: 1px;
    box-shadow: 0 0 0 1px var(--line), 0 8px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 70;
    pointer-events: none;
}

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

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

/* ---- Short / landscape viewports (<=620px height) ---- */
@media (max-height: 620px) {
    .menu-wrap {
        padding-top: 12px;
        padding-bottom: 12px;
        justify-content: flex-start;
    }

    .brand {
        margin-bottom: 12px;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        margin-bottom: 6px;
    }

    .brand-title {
        font-size: 24px;
        letter-spacing: 4px;
    }

    .brand-sub {
        font-size: 11px;
        letter-spacing: 2px;
    }

    .menu-actions {
        gap: 8px;
        max-width: 280px;
    }

    .btn {
        padding: 11px 14px;
        font-size: 14px;
        border-radius: 30px;
    }

    .topbar {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .topbar-title {
        font-size: 13px;
        letter-spacing: 2px;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
    }

    .icon-btn svg {
        width: 15px;
        height: 15px;
    }

    .game-wrap {
        gap: 3px;
        padding-left: 8px;
        padding-right: 8px;
        padding-bottom: 4px;
    }

    .player-panel {
        padding: 4px 10px;
        border-radius: 10px;
    }

    .pp-top {
        margin-bottom: 3px;
    }

    .pp-dot {
        width: 9px;
        height: 9px;
    }

    .pp-name {
        font-size: 10px;
    }

    .pp-turn-tag {
        font-size: 8px;
    }

    .pp-mid {
        gap: 6px;
        margin-bottom: 2px;
    }

    .wtool {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .wtool.h .bar {
        width: 20px;
        height: 5px;
    }

    .wtool.v .bar {
        width: 5px;
        height: 20px;
    }

    .pp-count-label {
        font-size: 8px;
        letter-spacing: 1px;
    }

    .pp-count-num {
        font-size: 17px;
    }

    .board-frame {
        padding: 4px;
        border-radius: 12px;
        max-width: 340px;
    }

    .status-line {
        min-height: 14px;
        font-size: 11px;
    }

    .modal-card {
        padding: 12px;
        border-radius: 14px;
        max-width: 410px;
        max-height: 78vh;
    }

    .modal-title {
        font-size: 15px;
    }

    .rule-text {
        font-size: 12px;
    }

    .rule-ico {
        width: 28px;
        height: 28px;
    }

    .rule-ico svg {
        width: 15px;
        height: 15px;
    }

    .win-title {
        font-size: 20px;
    }
}

/* ---- Very short viewports (<=480px height) ---- */
@media (max-height: 480px) {
    .topbar {
        padding-top: 2px;
        padding-bottom: 2px;
    }

    .topbar-title {
        font-size: 12px;
        letter-spacing: 1px;
    }

    .icon-btn {
        width: 30px;
        height: 30px;
    }

    .icon-btn svg {
        width: 13px;
        height: 13px;
    }

    .game-wrap {
        gap: 2px;
        padding-left: 6px;
        padding-right: 6px;
        padding-bottom: 2px;
    }

    .player-panel {
        padding: 3px 8px;
        border-radius: 8px;
    }

    .pp-mid {
        gap: 4px;
        margin-bottom: 1px;
    }

    .wtool {
        width: 30px;
        height: 30px;
        border-radius: 6px;
    }

    .wtool.h .bar {
        width: 16px;
        height: 4px;
    }

    .wtool.v .bar {
        width: 4px;
        height: 16px;
    }

    .pp-count-num {
        font-size: 14px;
    }

    .board-frame {
        padding: 3px;
        border-radius: 10px;
        max-width: 280px;
    }

    .status-line {
        min-height: 12px;
        font-size: 10px;
    }

    .pp-name {
        font-size: 9px;
    }

    .pp-dot {
        width: 7px;
        height: 7px;
    }
}

/* ---- Small phones (<=380px wide) ---- */
@media (max-width: 380px) {
    .brand-mark {
        width: 52px;
        height: 52px;
        margin-bottom: 8px;
    }

    .brand-title {
        font-size: 26px;
        letter-spacing: 4px;
    }

    .brand-sub {
        font-size: 11px;
        letter-spacing: 2px;
    }

    .menu-actions {
        max-width: 280px;
        gap: 10px;
    }

    .btn {
        padding: 12px 14px;
        font-size: 14px;
    }

    .topbar-title {
        font-size: 13px;
        letter-spacing: 2px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .icon-btn svg {
        width: 16px;
        height: 16px;
    }

    .game-wrap {
        padding-left: 8px;
        padding-right: 8px;
        gap: 4px;
    }

    .player-panel {
        padding: 6px 10px;
        border-radius: 11px;
    }

    .pp-name {
        font-size: 11px;
    }

    .pp-dot {
        width: 10px;
        height: 10px;
    }

    .pp-mid {
        gap: 6px;
    }

    .wtool {
        width: 40px;
        height: 40px;
        border-radius: 8px;
    }

    .wtool.h .bar {
        width: 22px;
        height: 5px;
    }

    .wtool.v .bar {
        width: 5px;
        height: 22px;
    }

    .pp-count-label {
        font-size: 8px;
    }

    .pp-count-num {
        font-size: 18px;
    }

    .status-line {
        font-size: 11px;
    }

    .board-frame {
        padding: 5px;
        border-radius: 13px;
    }

    .modal-card {
        padding: 14px;
        border-radius: 14px;
    }

    .modal-title {
        font-size: 15px;
    }

    .rule-text {
        font-size: 12px;
    }

    .win-title {
        font-size: 19px;
    }
}

/* ---- Very narrow phones (<=340px) ---- */
@media (max-width: 340px) {
    .wtool {
        width: 36px;
        height: 36px;
    }

    .pp-mid {
        gap: 5px;
    }

    .brand-title {
        font-size: 22px;
        letter-spacing: 3px;
    }

    .board-frame {
        max-width: 290px;
    }
}

/* ---- Wider tablets/desktop: cap board+panels ---- */
@media (min-width: 720px) {
    .board-frame {
        max-width: 440px;
    }

    .player-panel {
        max-width: 440px;
    }
}

/* ---- Tall desktops: comfortable sizing ---- */
@media (min-height: 900px) {
    .game-wrap {
        gap: 8px;
    }

    .player-panel {
        padding: 10px 16px;
    }

    .wtool {
        width: 52px;
        height: 52px;
    }

    .wtool.h .bar {
        width: 30px;
        height: 7px;
    }

    .wtool.v .bar {
        width: 7px;
        height: 30px;
    }

    .board-frame {
        padding: 8px;
        border-radius: 18px;
    }
}