/* RESET & BASE CSS */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
body { font-family: 'Fredoka', sans-serif; background-color: #f0fdf4; color: #1f2937; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.screen { display: none; width: 100%; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* 1. KOTAK TENGAH (LOBBY, TUNGGU, LEADERBOARD) */
.center-box { margin: auto; background: white; padding: 25px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); width: 90%; max-width: 450px; text-align: center; max-height: 90vh; display: flex; flex-direction: column; }
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.95rem; color: #374151; }
.form-control { width: 100%; padding: 12px 14px; border: 2px solid #e5e7eb; border-radius: 10px; font-size: 1rem; font-family: inherit; outline: none; }
.form-control:focus { border-color: #10b981; }

.btn { display: block; width: 100%; padding: 12px; border: none; border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer; font-family: inherit; transition: 0.1s; margin-bottom: 10px; }
.btn-green { background: #10b981; color: white; box-shadow: 0 4px 0 #059669; }
.btn-green:active { transform: translateY(3px); box-shadow: none; }
.btn-blue { background: #3b82f6; color: white; box-shadow: 0 4px 0 #2563eb; }
.btn-blue:active { transform: translateY(3px); box-shadow: none; }
.btn-orange { background: #f59e0b; color: white; box-shadow: 0 4px 0 #d97706; }
.btn-orange:active { transform: translateY(3px); box-shadow: none; }
.btn-share { background: #25d366; color: white; font-size: 0.95rem; padding: 10px; margin-bottom: 0; }

.player-badge-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 15px 0; overflow-y: auto; flex-grow: 1; min-height: 100px;}
.p-badge { background: #ecfdf5; border: 1.5px solid #a7f3d0; color: #065f46; padding: 6px 14px; border-radius: 20px; font-weight: 600; font-size: 0.9rem; }

/* 2. ARENA BERMAIN */
.header { background: #10b981; color: white; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; font-size: 1rem; font-weight: 600; box-shadow: 0 4px 6px rgba(0,0,0,0.1); z-index: 10; }
.game-layout { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }
@media (min-width: 768px) { .game-layout { flex-direction: row; } }

.canvas-area { flex-grow: 1; display: flex; flex-direction: column; background: #e5e7eb; position: relative; }
.canvas-wrapper { flex-grow: 1; display: flex; justify-content: center; align-items: center; padding: 8px; overflow: hidden; }
canvas { background: white; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); width: 100%; max-width: 600px; aspect-ratio: 4/3; touch-action: none; cursor: crosshair; }

/* TOOLS PENGGAMBAR */
.tools-bar { background: white; padding: 10px; display: none; justify-content: center; gap: 8px; border-top: 2px solid #e5e7eb; flex-wrap: wrap; }
.color-btn { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.color-btn.active { border-color: #374151; transform: scale(1.15); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.action-btn { background: #ef4444; color: white; border: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 0.9rem; margin-left: 5px; }

/* LIVE CHAT & GUESS AREA */
.side-panel { display: flex; flex-direction: column; width: 100%; height: 280px; background: white; border-top: 3px solid #e5e7eb; }
@media (min-width: 768px) { .side-panel { width: 320px; height: 100%; border-top: none; border-left: 3px solid #e5e7eb; } }

.chat-box { flex-grow: 1; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; background: #f9fafb; }
.chat-msg { padding: 4px 8px; border-radius: 6px; word-break: break-word; }
.msg-sys { color: #10b981; font-weight: bold; background: #ecfdf5; text-align: center; font-size: 0.85rem; padding: 6px; border-radius: 8px; }
.msg-alert { color: #d97706; font-weight: bold; background: #fef3c7; font-size: 0.85rem; padding: 6px; border-radius: 8px; text-align: center; }
.msg-correct { color: #047857; font-weight: bold; background: #d1fae5; border-left: 4px solid #10b981; }
.msg-player { color: #374151; }
.msg-player b { color: #2563eb; margin-right: 4px; }

.guess-controls { padding: 10px; background: white; border-top: 1px solid #e5e7eb; display: none; flex-direction: column; gap: 8px; }
.chat-input-wrapper { display: flex; gap: 8px; }
.chat-input { flex-grow: 1; padding: 10px; border: 2px solid #e5e7eb; border-radius: 8px; font-family: inherit; font-size: 1rem; outline: none; -webkit-user-select: auto; user-select: auto; }
.chat-input:focus { border-color: #3b82f6; }
.btn-send { background: #3b82f6; color: white; border: none; padding: 0 15px; border-radius: 8px; font-weight: bold; cursor: pointer; }

.scramble-letters { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.letter-btn { background: #f3f4f6; border: 1px solid #d1d5db; color: #374151; width: 34px; height: 34px; border-radius: 8px; font-size: 1rem; font-weight: 700; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 2px 0 #d1d5db; }
.letter-btn:active { transform: translateY(2px); box-shadow: none; }

/* KLASEMEN / LEADERBOARD */
.rank-list { list-style: none; overflow-y: auto; text-align: left; flex-grow:1; margin-bottom:15px; }
.rank-item { display: flex; justify-content: space-between; padding: 10px 15px; background: #f9fafb; border-radius: 10px; margin-bottom: 8px; font-weight: 600; border: 1px solid #e5e7eb; }
.rank-1 { background: #fefce8; border-color: #fef08a; color: #854d0e; font-size: 1.1rem; }
.rank-2 { background: #f8fafc; border-color: #cbd5e1; color: #334155; }
.rank-3 { background: #fff7ed; border-color: #ffedd5; color: #9a3412; }