@font-face { font-family: 'Nunito'; src: url('assets/nunito-v32-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('assets/nunito-v32-latin-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('assets/nunito-v32-latin-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
    --bg: #0f0518; --card: #1f1130; --text: #fff; --gold: #ffd700;
    --primary: #c30f16; --green: #2dc937; --danger: #ff4444;
    --font-header: 'Nunito', sans-serif; --font-body: 'Nunito', sans-serif;
}

/* 1. ABSOLUTE VIEWPORT CONTAINMENT */
html, body { margin: 0; padding: 0; width: 100vw; height: 100dvh; background: var(--bg); color: var(--text); font-family: var(--font-body); overflow: hidden; text-align: center; overscroll-behavior: none; }

body.on-fire { background: linear-gradient(0deg, #5a0000, #0f0518); animation: fire-pulse 0.5s infinite alternate; }
@keyframes fire-pulse { 0% { box-shadow: inset 0 0 20px #ff4444; } 100% { box-shadow: inset 0 0 50px #ffaa00; } }

.streak-anim { display: inline-block; animation: pulse-glow 1s infinite alternate; color: #ffaa00; text-shadow: 0 0 10px #ff0000; margin-left: 5px; font-family: var(--font-header); font-weight: 800; letter-spacing: 1px; }
@keyframes pulse-glow { 0% { transform: scale(1); } 100% { transform: scale(1.3); } }

audio { display: none; }
h1, h2, h3, .status-label, .round-label { font-family: var(--font-header); font-weight: 800; letter-spacing: 1px; }

.scramble-word, .answer-word, .slot { font-family: 'Nunito', sans-serif !important; font-weight: 800 !important; letter-spacing: 6px !important; text-transform: uppercase !important; }
.scramble-word { font-size: clamp(2rem, 7vmin, 5rem); color: var(--danger) !important; margin: 0; max-width: 100%; white-space: normal; word-break: break-word; line-height: 1.2; flex-shrink: 0;}

.shuffle-anim { animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both; }
@keyframes glitch { 0% { transform: translate(0) } 20% { transform: translate(-4px, 4px) rotate(-2deg) } 40% { transform: translate(-4px, -4px) } 60% { transform: translate(4px, 4px) rotate(2deg) } 80% { transform: translate(4px, -4px) } 100% { transform: translate(0) } }

.text-gold { color: var(--gold); } .text-primary { color: var(--primary); } .text-aaa { color: #aaa; } .text-white { color: white; }
.w-full { width: 100%; } .h-full { height: 100%; } .text-left { text-align: left; }
.flex-between { display: flex; justify-content: space-between; align-items: center; } 
.flex-col-center { display: flex; flex-direction: column; align-items: center; width: 100%; min-height:0; min-width:0; }
.fs-09 { font-size: 0.9rem; } .fs-12 { font-size: 1.2rem; } .fs-20 { font-size: 2rem; } .fs-25 { font-size: 2.5rem; } .fs-30 { font-size: 3rem; }
.mb-20 { margin-bottom: 20px; } .mt-5 { margin-top: 5px; } .mt-10 { margin-top: 10px; } .m-0 { margin: 0; } .fw-900 { font-weight: 800; }
.bg-red { background: linear-gradient(45deg, #880000, #ff0000) !important; }
.hidden { display: none !important; } .hidden-ui { display: none; }

/* CORE CONTAINER - ALWAYS 100% HEIGHT */
.container { height: 100dvh; width: 100vw; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2dvh 4vw; padding-bottom: max(2dvh, env(safe-area-inset-bottom, 2dvh)); box-sizing: border-box; min-width: 0; min-height: 0; }

.btn-action, .btn-host { padding: clamp(10px, 2vh, 16px) 20px; font-size: clamp(0.9rem, 2.5vh, 1.1rem); font-family: var(--font-header); font-weight: 800; white-space: normal; word-break: break-word; line-height: 1.3; text-align: center; background: linear-gradient(45deg, var(--primary), #ff4444); color: white; border: none; border-radius: 12px; cursor: pointer; box-shadow: 0 4px 15px rgba(195, 15, 22, 0.4); margin-top: 10px; transition: transform 0.1s, opacity 0.1s; width: 100%; box-sizing: border-box; display: block; touch-action: manipulation; flex-shrink: 0; }
.btn-action:active, .btn-host:active { transform: scale(0.95); }
#btn-init-lobby { font-size: 1.3rem !important; padding: 16px 40px !important; width: auto !important; margin-top: 30px !important; border-radius: 50px !important; margin-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important; }

.input-box { font-size: clamp(1.2rem, 3vh, 1.8rem); font-weight: 700; letter-spacing: 2px; padding: clamp(10px, 2vh, 15px); border-radius: 12px; border: 3px solid transparent; text-align: center; width: 85%; max-width: 400px; margin-bottom: 2vh; background: #333; color: white; font-family: var(--font-body); transition: border 0.3s; text-transform: uppercase; word-break: break-word; flex-shrink:0; }
.input-box:focus { outline: none; border-color: var(--gold); }
select.input-box { text-transform: none; font-size: 1.2rem; padding: 10px; cursor: pointer; }

#btn-fullscreen { position: fixed; top: 12px; left: 12px; z-index: 99999; background: rgba(0,0,0,0.5); border: 1px solid #555; color: #aaa; width: 40px; height: 40px; border-radius: 8px; font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: background 0.2s, color 0.2s; }

/* PLAYER PHONE UI FLUID STACK */
#p-game { height: 100%; justify-content: flex-start; padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* IRONCLAD SPLIT FIX FOR TV */
.host-grid-container { display: flex; width: 100vw; height: 100dvh; overflow: hidden; flex-direction: row; }
#panel-left { flex: 0 0 clamp(180px, 20vw, 250px); height: 100dvh; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; background: rgba(0,0,0,0.6); border-right: 2px solid #333; z-index: 20; padding: 2vh 1vw; box-sizing: border-box; justify-content: flex-start; align-items: center; }
#panel-right { flex: 1; min-width: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; position: relative; z-index: 10; }

#box-status { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width:100%; min-height: 0; gap: 2vh;}
#box-header { height: clamp(60px, 12vh, 100px); display: flex; align-items: center; justify-content: center; border-bottom: 2px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.4); overflow: hidden; flex-shrink: 0; padding: 0 15px; }
#box-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width:0; min-height:0; }
#game-stage { flex: 1; padding: 2vh 3vw; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height:0;}

.squircle-timer { font-size: clamp(2rem, 5vh, 4rem); color: var(--gold); border: clamp(2px, 0.5vh, 4px) solid var(--gold); border-radius: 20%; width: clamp(60px, 15vh, 100px); height: clamp(60px, 15vh, 100px); display: flex; align-items: center; justify-content: center; background: #000; font-family: var(--font-header); font-weight: 800; flex-shrink:0; }
.status-label { font-size: clamp(1rem, 2.5vh, 1.5rem); color: #aaa; }
.player-count { font-size: clamp(0.9rem, 2vh, 1.2rem); color: var(--green); font-weight: bold; margin: 1vh 0; }

/* SEAMLESS STOCK MARKET TICKER CLONE FIX */
.ticker-wrap { width: 100%; height: 100%; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: flex-start; white-space: nowrap; }
.ticker-move { display: flex; width: max-content; }
.ticker-move.scrolling { animation: seamless-scroll 20s linear infinite; }
@keyframes seamless-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.ticker-inner { display: flex; gap: 15px; padding-right: 15px; }

.lb-pill { background: #222; padding: 8px 16px; border-radius: 50px; border: 1px solid #444; font-weight: bold; font-size: clamp(1rem, 2.5vh, 1.4rem); display: flex; white-space: nowrap; flex-shrink: 0; align-items: center; gap: 6px; }
.lb-pill.top { border-color: var(--gold); color: var(--gold); }
.p-name-container { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 10ch; flex-shrink: 1; min-width: 0; }
.lb-score { color: var(--green); margin-left: auto; font-family: var(--font-header); letter-spacing: 1px; font-weight: 700; }

.answer-word { font-size: clamp(2rem, 6vmin, 4.5rem); color: var(--green); margin-top: 10px; word-break: break-word; }
.hint-text { font-size: clamp(1rem, 3.5vmin, 1.8rem); color: #dedede; margin-bottom: 10px; font-style: italic; font-weight: 600; font-family: var(--font-body); text-align: center; word-break: break-word;}

.slots-container { display: flex; gap: clamp(5px, 1.5vw, 10px); margin-top: 15px; justify-content: center; flex-wrap: wrap; }
.slot { width: clamp(20px, 4vw, 50px); height: clamp(30px, 6vh, 60px); border-bottom: clamp(2px, 0.5vh, 4px) solid white; font-size: clamp(1.5rem, 4vh, 2.5rem); color: var(--green); display: flex; align-items: center; justify-content: center; flex-shrink: 0;}
.slot-spacer { flex-basis: 100%; height: 10px; }

.winner-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;}
.winner-title { font-size: clamp(3rem, 10vmin, 8rem); color: var(--gold); margin: 0; font-family: var(--font-header); font-weight: 800; text-align: center;}
.winner-name { font-size: clamp(2rem, 8vmin, 6rem); color: white; margin-top: 2vh; font-family: var(--font-header); font-weight: 800; word-break: break-word; text-align: center;}
.confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5000; }

.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(clamp(100px, 15vw, 150px), 1fr)); gap: clamp(5px, 1.5vh, 15px); width: 100%; overflow-y: auto; height: 100%; padding-right: 10px; align-content: start; }
.lobby-card { background: #222; padding: clamp(8px, 1.5vh, 15px); border-radius: 8px; font-weight: bold; font-size: clamp(0.9rem, 2.5vh, 1.3rem); display: flex; justify-content: center; align-items: center; border: 1px solid #444; word-break: break-word; text-align: center;}

.warning-box { background: #222; padding: 30px; border-radius: 15px; border: 3px solid var(--danger); text-align: center; box-shadow: 0 0 50px rgba(255,0,0,0.5); width: clamp(280px, 80vw, 500px); }
.emoji-btn { cursor: pointer; opacity: 0.4; transition: transform 0.2s, opacity 0.2s, border 0.2s; padding-bottom: 5px; user-select: none; }
.emoji-btn.selected { opacity: 1; transform: scale(1.3); border-bottom: 3px solid var(--gold); }

#wrong-guess-container { position: fixed; bottom: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; overflow: hidden; }
.wrong-bubble { position: absolute; bottom: -50px; padding: 10px 20px; background: rgba(195, 15, 22, 0.95); color: white; border-radius: 30px; font-family: var(--font-header); font-weight: 800; font-size: clamp(1rem, 3vmin, 1.5rem); box-shadow: 0 5px 15px rgba(0,0,0,0.6); white-space: nowrap; transform: translateX(-50%); animation: floatUp 3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
@keyframes floatUp { 0% { bottom: -50px; opacity: 1; transform: translateX(-50%) scale(0.5); } 15% { transform: translateX(-50%) scale(1.1); } 100% { bottom: 60%; opacity: 0; transform: translateX(-50%) scale(1); } }

.fastest-banner { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: linear-gradient(90deg, #ff8c00, #ff0055); color: white; padding: 15px 40px; border-radius: 50px; font-family: var(--font-header); font-weight:800; font-size: clamp(1.2rem, 3vw, 1.8rem); box-shadow: 0 10px 20px rgba(0,0,0,0.5); z-index: 50; white-space: nowrap; }
@keyframes slideUpFade { 0% { opacity: 0; bottom: -50px; } 100% { opacity: 1; bottom: 20px; } }

.floating-score { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); font-family: var(--font-header); font-weight: 800; font-size: clamp(3rem, 10vh, 6rem); text-shadow: 0 5px 15px rgba(0,0,0,0.8); pointer-events: none; z-index: 9999; animation: floatUpText 2s forwards; }
@keyframes floatUpText { 0% { opacity: 0; transform: translate(-50%, -20%) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } 80% { opacity: 1; transform: translate(-50%, -70%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -100%) scale(1); } }

.shake { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(4px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-6px, 0, 0); } 40%, 60% { transform: translate3d(6px, 0, 0); } }

.orientation-warning { position: fixed; inset: 0; background: var(--bg); z-index: 99999; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.orientation-warning h1 { font-size: 5rem; margin: 0 0 20px 0; } .orientation-warning h2 { font-size: 2rem; color: var(--gold); }
@media (orientation: portrait) { body.host-client #landscape-warning { display: flex !important; } body.host-client .host-ui-wrap, body.host-client .host-grid-container { display: none !important; } }
