/* =========================================================
   ห้ามพูด! — Design tokens
   แนวคิด: "คำต้องห้าม" ตีความเป็นแถบเซ็นเซอร์ดำ + ตราปั๊มยางแดง
   สไตล์เวทีเกมโชว์ยามค่ำคืน: พื้นหลังเข้ม ป้ายไฟนีออน การ์ดกระดาษสีครีม
   ========================================================= */

:root {
    /* พื้นเวที (โทนเข้ม) */
    --ink: #15111F;
    --ink-soft: #211A33;
    --ink-softer: #2B2247;
    --ink-line: rgba(255, 255, 255, 0.09);

    /* การ์ด/แผ่นกระดาษ (โทนสว่าง) */
    --paper: #FBF7EC;
    --paper-dim: #EFE7D3;
    --paper-line: rgba(31, 23, 48, 0.12);

    /* สีไฟนีออน / accent */
    --pink: #FF3E7F;
    --pink-dark: #D6265E;
    --yellow: #FFCC33;
    --yellow-dark: #E0A800;
    --mint: #2AE6B8;
    --mint-dark: #16BE94;
    --violet: #8C6BFF;
    --stamp: #E2373B;
    --stamp-dark: #B8262A;

    /* ตัวอักษร */
    --text-on-dark: #F6F2FF;
    --text-on-dark-muted: #B3A8D6;
    --text-ink: #211935;
    --text-ink-muted: #6D6486;

    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 9px;
    --shadow-pop: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

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

body {
    margin: 0;
    font-family: 'Mitr', 'Segoe UI', sans-serif;
    background:
        radial-gradient(circle at 18% -10%, rgba(255, 62, 127, 0.20), transparent 42%),
        radial-gradient(circle at 88% 8%, rgba(42, 230, 184, 0.14), transparent 40%),
        var(--ink);
    background-attachment: fixed;
    color: var(--text-on-dark);
    min-height: 100vh;
}

.font-display {
    font-family: 'Chonburi', 'Mitr', sans-serif;
}
.font-mono {
    font-family: 'Space Mono', monospace;
}

a { color: inherit; }

::selection { background: var(--pink); color: #fff; }

/* focus visibility for keyboard users */
button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid var(--mint);
    outline-offset: 2px;
}

/* =========================================================
   Layout wrap
   ========================================================= */

.wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 28px 16px 90px;
    min-height: 100vh;
}

/* =========================================================
   Landing page — hero
   ========================================================= */

.landing {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    color: var(--text-on-dark-muted);
    font-size: 12.5px;
    padding: 6px 14px;
    border-radius: 999px;
    letter-spacing: .3px;
}

.hero {
    text-align: center;
    position: relative;
}

.hero-title-wrap {
    position: relative;
    display: inline-block;
}

.hero-title {
    font-size: 56px;
    line-height: 1.1;
    margin: 10px 0 6px;
    color: var(--text-on-dark);
    text-shadow: 0 4px 0 rgba(0,0,0,0.25);
    position: relative;
    z-index: 1;
}

.hero-title .accent { color: var(--yellow); }

.censor-bar {
    position: absolute;
    inset: 6px -8px;
    background: #0B0812;
    border-radius: 6px;
    z-index: 2;
    transform-origin: left center;
    animation: uncensor 1.1s 0.35s cubic-bezier(.7,0,.2,1) forwards;
}

@keyframes uncensor {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

.hero-sub {
    color: var(--text-on-dark-muted);
    font-size: 15px;
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.7;
}

/* =========================================================
   Cards (game-show panels)
   ========================================================= */

.card {
    background: var(--paper);
    color: var(--text-ink);
    border-radius: var(--radius-lg);
    padding: 26px;
    width: 100%;
    box-shadow: var(--shadow-pop);
    border: 1px solid rgba(0,0,0,0.05);
}

.panel-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-pop);
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
}
.panel-create::before { background: linear-gradient(90deg, var(--pink), var(--violet)); }
.panel-join::before { background: linear-gradient(90deg, var(--mint), var(--yellow)); }

.panel h2 {
    font-family: 'Chonburi', 'Mitr', sans-serif;
    font-size: 19px;
    margin: 6px 0 14px;
    color: var(--text-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

form { display: flex; flex-direction: column; gap: 10px; }

input[type="text"] {
    padding: 14px 16px;
    border: 2px solid var(--paper-line);
    background: #fff;
    border-radius: var(--radius-sm);
    font-family: 'Mitr', sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color .15s, transform .1s;
    color: var(--text-ink);
}
input[type="text"]::placeholder { color: #B3A9C7; }
input[type="text"]:focus { border-color: var(--violet); }

/* =========================================================
   Buttons — "game buzzer" tactile press
   ========================================================= */

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-family: 'Mitr', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .08s ease, opacity .15s, filter .15s;
    position: relative;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.btn-primary {
    background: var(--pink);
    color: #fff;
    box-shadow: 0 5px 0 var(--pink-dark);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--pink-dark); }

.btn-secondary {
    background: var(--yellow);
    color: #3A2600;
    box-shadow: 0 5px 0 var(--yellow-dark);
}
.btn-secondary:active:not(:disabled) { box-shadow: 0 2px 0 var(--yellow-dark); }

.btn-mint {
    background: var(--mint);
    color: #06332A;
    box-shadow: 0 5px 0 var(--mint-dark);
}
.btn-mint:active:not(:disabled) { box-shadow: 0 2px 0 var(--mint-dark); }

.btn-outline {
    background: transparent;
    color: var(--text-ink);
    border: 2px solid var(--paper-line);
}
.btn-outline:active { transform: translateY(1px); }

.btn-danger {
    background: var(--stamp);
    color: #fff;
    box-shadow: 0 5px 0 var(--stamp-dark);
}
.btn-danger:active:not(:disabled) { box-shadow: 0 2px 0 var(--stamp-dark); }

.btn-copy { background: var(--ink-soft); color: var(--text-on-dark); font-size: 13px; padding: 9px 14px; border: 1px solid var(--ink-line); }
.btn-leave { background: transparent; color: #FF9EB8; font-size: 13px; padding: 9px 14px; border: 1px solid rgba(255,62,127,0.4); }
.btn-leave:hover { background: rgba(255,62,127,0.12); }

.btn-sm { padding: 8px 12px; font-size: 13px; box-shadow: 0 3px 0 rgba(0,0,0,0.2); }

.divider {
    text-align: center;
    color: var(--text-on-dark-muted);
    font-size: 12.5px;
    position: relative;
    width: 100%;
}
.divider span {
    background: var(--ink);
    padding: 0 12px;
    position: relative;
    z-index: 1;
}
.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--ink-line);
}

.alert {
    background: rgba(226, 55, 59, 0.15);
    border: 1px solid rgba(226, 55, 59, 0.4);
    color: #FFC7C9;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 100%;
}

.steps-strip {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-on-dark-muted);
    font-size: 13px;
}
.step-row { display: flex; gap: 10px; align-items: flex-start; }
.step-num {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: var(--ink);
    background: var(--yellow);
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
}
.step-row b { color: var(--text-on-dark); }

.footnote {
    text-align: center;
    color: rgba(179, 168, 214, 0.6);
    font-size: 11.5px;
    margin-top: 4px;
}

/* =========================================================
   Room page
   ========================================================= */

.room-shell {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.scoreboard {
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ticket {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ticket-label { font-size: 10.5px; color: var(--text-on-dark-muted); text-transform: uppercase; letter-spacing: 1px; display: block; }
.ticket-code {
    font-family: 'Space Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--yellow);
}
.live-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 0 rgba(42,230,184,0.6);
    animation: livepulse 1.8s infinite;
    flex-shrink: 0;
}
@keyframes livepulse {
    0% { box-shadow: 0 0 0 0 rgba(42,230,184,0.55); }
    70% { box-shadow: 0 0 0 8px rgba(42,230,184,0); }
    100% { box-shadow: 0 0 0 0 rgba(42,230,184,0); }
}

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

.stage-panel {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    color: var(--text-ink);
    box-shadow: var(--shadow-pop);
}
.stage-emoji { font-size: 34px; margin-bottom: 6px; }
.stage-text { font-family: 'Chonburi', 'Mitr', sans-serif; font-size: 19px; color: var(--text-ink); }
.stage-sub { font-size: 13px; color: var(--text-ink-muted); margin-top: 6px; }

.my-word-notice {
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    color: var(--text-on-dark);
    font-size: 13.5px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    line-height: 1.6;
    text-align: center;
}

.winner-banner {
    background: linear-gradient(120deg, var(--yellow), #FFE28A);
    color: #3A2600;
    text-align: center;
    font-family: 'Chonburi', 'Mitr', sans-serif;
    font-size: 20px;
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    animation: winnerPop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes winnerPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.host-dock {
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.host-dock .btn { flex: 1; min-width: 120px; }
.host-dock-label {
    width: 100%;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-on-dark-muted);
    margin-bottom: 2px;
}

.players-title {
    font-size: 13px;
    letter-spacing: .5px;
    margin: 4px 2px;
    color: var(--text-on-dark-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.players-count {
    font-family: 'Space Mono', monospace;
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
}

.player-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- player card --- */
.player-card {
    position: relative;
    background: var(--paper);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0,0,0,0.22);
    animation: cardIn .35s ease both;
    border: 2px solid transparent;
}
.player-card.is-me { border-color: var(--violet); }
.player-card.out { filter: grayscale(0.5); opacity: .72; }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(6px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.player-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.player-name {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text-ink);
    display: flex;
    align-items: center;
    gap: 5px;
}
.player-name .crown { font-size: 13px; }

/* speech-bubble word chip for OTHER players' visible words */
.player-word {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: var(--violet);
    padding: 5px 12px 5px 12px;
    border-radius: 999px;
    display: inline-block;
    width: fit-content;
    position: relative;
    animation: wordPop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes wordPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* censor bar for own hidden word */
.player-word.hidden-word {
    background: repeating-linear-gradient(
        135deg,
        #0B0812,
        #0B0812 6px,
        #1c1526 6px,
        #1c1526 12px
    );
    color: var(--text-on-dark-muted);
    font-weight: 700;
    letter-spacing: 1px;
}

.player-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* elimination rubber stamp */
.stamp-out {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg) scale(0);
    font-family: 'Chonburi', 'Mitr', sans-serif;
    font-size: 20px;
    color: var(--stamp);
    border: 3px solid var(--stamp);
    padding: 2px 14px;
    border-radius: 8px;
    letter-spacing: 2px;
    opacity: 0.88;
    pointer-events: none;
    animation: stampSlam .35s cubic-bezier(.2,1.4,.6,1) forwards;
    background: rgba(226,55,59,0.06);
}
@keyframes stampSlam {
    0% { transform: translate(-50%, -50%) rotate(-12deg) scale(2.4); opacity: 0; }
    60% { transform: translate(-50%, -50%) rotate(-12deg) scale(0.9); opacity: 0.95; }
    100% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); opacity: 0.88; }
}

.hint {
    font-size: 12.5px;
    color: var(--text-on-dark-muted);
    line-height: 1.7;
    text-align: center;
    padding: 0 6px;
}

/* =========================================================
   Toast
   ========================================================= */

.toast-host {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(92vw, 380px);
}

.toast {
    background: var(--ink-soft);
    border: 1px solid var(--ink-line);
    color: var(--text-on-dark);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    box-shadow: var(--shadow-pop);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity .22s ease, transform .22s ease;
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-hide { opacity: 0; transform: translateY(-8px); }
.toast-success { border-color: rgba(42,230,184,0.5); }
.toast-error { border-color: rgba(226,55,59,0.5); }

/* =========================================================
   Confirm modal
   ========================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 7, 18, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity .18s ease;
    padding: 20px;
}
.modal-overlay.modal-show { opacity: 1; }

.modal-box {
    background: var(--paper);
    color: var(--text-ink);
    border-radius: var(--radius-lg);
    padding: 22px;
    width: 100%;
    max-width: 340px;
    box-shadow: var(--shadow-pop);
    transform: scale(0.92);
    transition: transform .18s ease;
}
.modal-overlay.modal-show .modal-box { transform: scale(1); }

.modal-title {
    font-family: 'Chonburi', 'Mitr', sans-serif;
    font-size: 17px;
    margin-bottom: 8px;
}
.modal-msg { font-size: 14px; color: var(--text-ink-muted); line-height: 1.6; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* =========================================================
   Confetti
   ========================================================= */

.confetti-host {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9997;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    top: -12px;
    border-radius: 2px;
    animation-name: confettiFall;
    animation-timing-function: cubic-bezier(.3,0,.7,1);
    animation-fill-mode: forwards;
    opacity: 0.95;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(105vh) rotate(540deg); opacity: 0.4; }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 480px) {
    .card, .panel, .stage-panel { padding: 18px; border-radius: var(--radius-md); }
    .hero-title { font-size: 42px; }
    .ticket-code { font-size: 20px; letter-spacing: 3px; }
}
