/*** Base ***/
* { box-sizing:border-box; }
html, body { margin:0; padding:0; height:100%; }
body { background:#1b1640; background:linear-gradient(160deg, #2a1f63 0%, #1b1640 55%, #120e2c 100%); color:#fff; font-family:"Segoe UI", Roboto, Helvetica, Arial, sans-serif; overflow-x:hidden; }
button { font-family:inherit; cursor:pointer; }
#app { min-height:100%; display:flex; flex-direction:column; }
.hidden { display:none !important; }
.logo { font-size:56px; font-weight:800; letter-spacing:1px; color:#ffd166; text-shadow:0 4px 0 #b8860b; }
.center_msg { min-height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:20px; }
	.center_msg .msg_text { font-size:22px; margin-top:20px; opacity:0.85; }
	.center_msg .join_form { margin-top:30px; }

/*** Answer colors ***/
.a0 { background:#ef5b5b; }
.a1 { background:#20a39e; }
.a2 { background:#f0a202; }
.a3 { background:#7b5ea7; }
.letter { display:inline-flex; align-items:center; justify-content:center; width:1.6em; height:1.6em; border-radius:50%; background:rgba(0,0,0,0.22); font-weight:800; flex-shrink:0; }

/*** Buttons ***/
.btn { background:#ffd166; color:#1b1640; border:0; border-radius:12px; padding:14px 30px; font-size:22px; font-weight:800; box-shadow:0 5px 0 #b8860b; transition:transform 0.08s; }
	.btn:active { transform:translateY(3px); box-shadow:0 2px 0 #b8860b; }
	.btn.grey { background:#d6d3e8; box-shadow:0 5px 0 #8c88a8; }

/*** Host: bar ***/
.host_bar { display:flex; justify-content:flex-end; align-items:center; gap:15px; padding:20px 30px 20px 290px; }
	.host_bar .hint { margin-right:auto; opacity:0.5; font-size:15px; }
	.yt_on .host_bar { padding-left:460px; }

/*** Host: music buttons ***/
.music_box { position:fixed; bottom:26px; left:24px; z-index:10; display:flex; gap:8px; }
	.yt_on .music_box { left:192px; }
.music_btn { background:rgba(255,255,255,0.12); color:#fff; border:0; border-radius:20px; padding:7px 16px; font-size:15px; font-weight:700; }
	.music_btn:hover { background:rgba(255,255,255,0.22); }
	.music_btn.off { opacity:0.5; text-decoration:line-through; }

/*** Host: music choice panel ***/
.music_panel { position:fixed; bottom:76px; left:24px; z-index:20; width:400px; background:#fff; color:#1b1640; border-radius:16px; padding:20px; box-shadow:0 10px 40px rgba(0,0,0,0.45); }
	.music_panel .panel_title { font-size:22px; font-weight:800; margin-bottom:15px; }
	.music_panel .panel_row { margin-bottom:14px; }
	.music_panel .panel_label { font-size:14px; font-weight:700; opacity:0.65; margin-bottom:5px; }
	.music_panel .panel_line { display:flex; gap:8px; }
	.music_panel .panel_input { flex:1; width:100%; font-family:inherit; font-size:16px; padding:8px 10px; border:2px solid #d6d3e8; border-radius:8px; color:#1b1640; background:#fff; }
	.music_panel .yt_input { margin-top:8px; }
	.music_panel .preview_btn { border:0; border-radius:8px; background:#d6d3e8; color:#1b1640; font-size:16px; font-weight:800; width:44px; }
		.music_panel .preview_btn.on { background:#ffd166; }
	.music_panel .panel_error { color:#c0392b; font-size:14px; min-height:18px; margin-top:4px; }
	.music_panel .panel_hint { font-size:13px; opacity:0.6; margin-bottom:15px; }
	.music_panel .btn { font-size:16px; padding:10px 22px; box-shadow:0 3px 0 #8c88a8; }
.yt_box { position:fixed; bottom:16px; left:16px; z-index:10; width:160px; height:90px; border-radius:8px; overflow:hidden; background:#000; box-shadow:0 4px 14px rgba(0,0,0,0.4); }
	.yt_box iframe { display:block; width:100%; height:100%; }

/*** Host: lobby ***/
.lobby { flex:1; display:flex; gap:40px; padding:40px; }
	.lobby_join { width:42%; background:rgba(255,255,255,0.07); border-radius:24px; padding:35px; text-align:center; display:flex; flex-direction:column; align-items:center; justify-content:center; }
	.lobby_join .join_label { font-size:24px; margin-top:25px; opacity:0.8; }
	.lobby_join .join_url { font-size:30px; font-weight:800; margin:10px 0 20px; white-space:nowrap; }
		.lobby_join .join_url.online { font-size:26px; white-space:normal; }
	.lobby_join .join_hint { font-size:16px; opacity:0.6; margin-top:20px; }
	.lobby_join .other_ips { font-size:14px; opacity:0.45; margin-top:8px; }
	#qr { background:#fff; padding:14px; border-radius:14px; }
		#qr img, #qr canvas { display:block; }
	.lobby_players { flex:1; }
	.lobby_count { font-size:30px; font-weight:700; margin-bottom:20px; }
	.players_list { display:flex; flex-wrap:wrap; gap:12px; }
	.player_chip { background:#fff; color:#1b1640; font-size:24px; font-weight:700; padding:10px 20px; border-radius:30px; cursor:pointer; animation:pop 0.3s ease-out; }
		.player_chip:hover { background:#ef5b5b; color:#fff; text-decoration:line-through; }
	.lobby_empty { font-size:22px; opacity:0.5; }

/*** Host: question ***/
.q_top { display:flex; justify-content:space-between; padding:25px 35px 0; font-size:24px; font-weight:600; opacity:0.85; }
.q_text { background:#fff; color:#1b1640; font-size:46px; font-weight:800; text-align:center; margin:25px 35px; padding:35px 40px; border-radius:20px; line-height:1.2; }
.q_middle { flex:1; display:flex; align-items:center; justify-content:center; min-height:150px; }
.timer { width:130px; height:130px; border-radius:50%; background:#ffd166; color:#1b1640; font-size:60px; font-weight:800; display:flex; align-items:center; justify-content:center; }
	.timer.low { background:#ef5b5b; color:#fff; animation:pulse 1s infinite; }
.timer_bar { height:8px; margin:0 35px; background:rgba(255,255,255,0.1); border-radius:4px; overflow:hidden; }
	#timer_fill { height:100%; background:#ffd166; width:100%; transition:width 0.1s linear; }
.answers { display:grid; grid-template-columns:1fr 1fr; gap:15px; padding:20px 35px 0; }
	.answer_tile { display:flex; align-items:center; gap:18px; font-size:32px; font-weight:700; padding:28px 25px; border-radius:16px; position:relative; transition:opacity 0.3s, transform 0.3s; }
	.answer_tile .tile_text { flex:1; }
	.answer_tile .tile_count { font-size:30px; font-weight:800; }
	.answers.revealed .answer_tile.wrong { opacity:0.3; }
	.answers.revealed .answer_tile.correct { transform:scale(1.03); box-shadow:0 0 0 5px #fff; }
		.answers.revealed .answer_tile.correct .tile_text:after { content:" ✔"; }

/*** Host: reveal chart ***/
.chart { display:flex; align-items:flex-end; justify-content:center; gap:30px; height:100%; padding-top:15px; }
	.chart_col { width:90px; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:170px; }
	.chart_col .bar { width:100%; border-radius:8px 8px 0 0; min-height:6px; transition:height 0.6s ease-out; }
	.chart_col .num { font-size:26px; font-weight:800; margin-bottom:6px; }
	.chart_col.wrong { opacity:0.35; }

/*** Host: scoreboard ***/
.board_title { font-size:44px; font-weight:800; text-align:center; padding-top:35px; }
.board { flex:1; width:100%; max-width:900px; margin:30px auto 0; padding:0 30px; }
	.board_row { display:flex; align-items:center; gap:20px; background:#fff; color:#1b1640; border-radius:14px; padding:16px 25px; margin-bottom:12px; font-size:30px; font-weight:700; animation:slide_in 0.4s ease-out both; }
	.board_row .pos { width:50px; font-weight:800; color:#7b5ea7; }
	.board_row .name { flex:1; }
	.board_row .gain { font-size:22px; color:#20a39e; }
	.board_row .score { font-weight:800; min-width:110px; text-align:right; }

/*** Host: podium ***/
.podium { display:flex; align-items:flex-end; justify-content:center; gap:20px; margin-top:40px; }
	.podium_place { width:220px; text-align:center; visibility:hidden; }
		.podium_place.shown { visibility:visible; animation:rise 0.8s ease-out 0.6s both; }
		.podium_place.shown.no_anim { animation:none; }
		.podium_place.place1.shown .block { animation:winner_glow 1.2s ease-in-out 1.4s 2 alternate; }
	.podium_place .p_name { font-size:30px; font-weight:800; margin-bottom:5px; word-break:break-word; }
	.podium_place .p_score { font-size:20px; opacity:0.85; margin-bottom:10px; }
	.podium_place .block { border-radius:14px 14px 0 0; font-size:70px; font-weight:800; display:flex; align-items:flex-start; justify-content:center; padding-top:15px; }
	.podium_place.place1 .block { height:240px; background:#ffd166; color:#1b1640; }
	.podium_place.place2 .block { height:170px; background:#d6d3e8; color:#1b1640; }
	.podium_place.place3 .block { height:120px; background:#e0965a; color:#1b1640; }
.rest_list { text-align:center; margin-top:25px; font-size:20px; opacity:0.75; }

/*** Player ***/
body.player { user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }
body.player.good { background:#1f8a5b; }
body.player.bad { background:#b8394a; }
.p_head { display:flex; justify-content:space-between; align-items:center; padding:12px 16px; background:rgba(0,0,0,0.2); font-size:17px; font-weight:700; }
.p_center { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:20px 16px; }
	.p_center .logo { font-size:44px; margin-bottom:30px; }
	.p_center .big { font-size:38px; font-weight:800; margin-bottom:10px; }
	.p_center .mid { font-size:22px; font-weight:700; margin-bottom:8px; }
	.p_center .small { font-size:17px; opacity:0.8; }
	.p_center .points { font-size:48px; font-weight:800; background:rgba(0,0,0,0.2); border-radius:14px; padding:6px 24px; margin:10px 0 20px; }
.join_form { width:100%; max-width:340px; }
	.join_form input { width:100%; font-size:24px; font-weight:700; text-align:center; padding:14px; border:0; border-radius:12px; margin-bottom:15px; font-family:inherit; color:#1b1640; }
	.join_form .btn { width:100%; }
	.join_error { color:#ffb3b3; font-size:17px; min-height:24px; margin-top:12px; }
.p_question { font-size:18px; font-weight:600; text-align:center; padding:14px 16px 6px; opacity:0.9; }
.p_timer { text-align:center; font-size:15px; opacity:0.7; padding-bottom:8px; }
.p_answers { flex:1; display:grid; grid-template-columns:1fr 1fr; gap:10px; padding:10px; }
	.p_answers.two { grid-template-columns:1fr; }
	.p_answer { border:0; border-radius:16px; color:#fff; font-size:20px; font-weight:700; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; padding:12px; box-shadow:0 5px 0 rgba(0,0,0,0.3); }
		.p_answer .letter { font-size:26px; }
		.p_answer:active { transform:translateY(3px); box-shadow:0 2px 0 rgba(0,0,0,0.3); }
.chosen { width:90px; height:90px; border-radius:20px; display:flex; align-items:center; justify-content:center; font-size:46px; font-weight:800; margin-bottom:20px; }
.spinner { width:44px; height:44px; border:5px solid rgba(255,255,255,0.25); border-top-color:#ffd166; border-radius:50%; animation:spin 0.9s linear infinite; margin:25px auto 0; }

/*** Theme: Latvia (config 'theme'=>'latvia') ***/
.theme_latvia body { background-color:#9e3039; background-image:linear-gradient(180deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.08) 40%, rgba(255,255,255,0.08) 60%, rgba(255,255,255,0) 60%), linear-gradient(160deg, #a8343f 0%, #8a2631 50%, #5c1820 100%); background-repeat:no-repeat; background-size:100% 100%; background-attachment:fixed; }
	.theme_latvia .logo:before { content:""; display:inline-block; width:0.9em; height:0.45em; margin-right:0.25em; vertical-align:0.12em; background:linear-gradient(180deg, #9e3039 40%, #fff 40%, #fff 60%, #9e3039 60%); border:3px solid #fff; border-radius:3px; box-shadow:0 4px 0 #b8860b; }
	.theme_latvia body.player.bad { background:#3b2433; }

/*** Animations ***/
@keyframes pop { 0% { transform:scale(0.5); opacity:0; } 100% { transform:scale(1); opacity:1; } }
@keyframes pulse { 0%, 100% { transform:scale(1); } 50% { transform:scale(1.08); } }
@keyframes slide_in { 0% { transform:translateX(-40px); opacity:0; } 100% { transform:translateX(0); opacity:1; } }
@keyframes rise { 0% { transform:translateY(80px); opacity:0; } 100% { transform:translateY(0); opacity:1; } }
@keyframes spin { 100% { transform:rotate(360deg); } }
@keyframes winner_glow { 0% { box-shadow:0 0 0 0 rgba(255,209,102,0); } 100% { box-shadow:0 0 45px 12px rgba(255,209,102,0.75); } }

/*** Responsive ***/
@media (max-width:900px) {
	.lobby { flex-direction:column; padding:20px; }
		.lobby_join { width:100%; }
	.q_text { font-size:28px; padding:20px; }
	.answer_tile { font-size:22px; padding:18px; }
	.answers { grid-template-columns:1fr; }
}
