* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Roboto, system-ui, sans-serif; }
html, body { height: 100%; width: 100%; overflow: hidden; background: linear-gradient(145deg, #0b1a2e, #1a2f44); }

#app { display: flex; align-items: stretch; justify-content: stretch; width: 100vw; height: 103vh; }

.game-container {
    display: flex; flex-direction: column; flex: 1;
    background: rgba(255,255,255,0.08); backdrop-filter: blur(6px);
    padding: 12px 400px 12px 400px; width: 90%; height: 90%; overflow: hidden;
}

.header { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; margin-bottom: 6px; }
h1 { color: #e8edf5; font-weight: 500; font-size: 1.4rem; text-shadow: 0 2px 4px rgba(0,0,0,0.4); }

.user-area { display: flex; align-items: center; gap: 6px; color: #b0c9e0; background: rgba(0,0,0,0.2); padding: 2px 12px; border-radius: 40px; font-size: 0.9rem; }
.user-area span { font-weight: 600; color: #fff; }

.icon-btn { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 40px; padding: 4px 10px; color: #eef4fa; cursor: pointer; transition: 0.2s; font-size: 0.9rem; line-height: 1.4; }
.icon-btn:hover { background: rgba(255,255,255,0.18); }
.icon-btn.active { background: rgba(46,213,115,0.2); border-color: #2ed573; }

.top-bar { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.25); padding: 4px 12px; border-radius: 40px; flex-shrink: 0; margin-bottom: 8px; }

.stats { display: flex; gap: 12px; color: #b0c9e0; font-size: 0.8rem; flex-wrap: nowrap; overflow-x: auto; }
.stats span { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.stats span i { width: 16px; font-size: 0.8rem; }
.stats .record { color: #ffd93d; }
.player-score { color: #4fc3f7; cursor: pointer; }
.player-score.active { color: #ffd93d; }

.timer { font-size: 2.1rem; font-weight: 700; color: #ffd93d; background: rgba(0,0,0,0.3); padding: 0 12px; border-radius: 40px; min-width: 50px; text-align: center; }
.timer.warning { color: #ff6b6b; animation: pulse 0.6s infinite alternate; }

@keyframes pulse { 0% { opacity: 0.6; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1.05); } }

.settings-row { display: flex; flex-wrap: nowrap; gap: 6px; margin-bottom: 10px; background: rgba(0,0,0,0.15); padding: 4px 8px; border-radius: 40px; justify-content: space-between; align-items: center; overflow-x: auto; flex-shrink: 0; }

.setting-item { display: flex; align-items: center; gap: 3px; color: #b0c9e0; font-size: 0.75rem; flex-shrink: 0; }
.setting-item i { font-size: 0.85rem; width: 18px; text-align: center; }
.setting-item select, .setting-item .dir-switch { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 30px; padding: 2px 6px; color: #eef4fa; font-size: 0.75rem; cursor: pointer; outline: none; height: 24px; }
.setting-item select option { background: #1a2f44; color: #fff; }
.setting-item .dir-switch { display: flex; gap: 1px; padding: 1px 3px; height: 24px; }
.setting-item .dir-switch label { padding: 0 6px; border-radius: 20px; cursor: pointer; font-weight: 500; color: #b0c9e0; transition: 0.2s; font-size: 0.7rem; line-height: 20px; }
.setting-item .dir-switch input[type="radio"] { display: none; }
.setting-item .dir-switch input[type="radio"]:checked + label { background: rgba(74,125,170,0.6); color: #fff; }
.setting-item .dir-switch label:hover { background: rgba(255,255,255,0.05); }
.setting-item .icon-btn { font-size: 0.8rem; padding: 2px 8px; height: 24px; line-height: 1.2; border-radius: 30px; }

.word-card { background: rgba(255,255,255); border-radius: 28px; padding: 0px 10px 8px; margin-bottom: 12px; text-align: center; border: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; overflow: hidden; }
.direction-label { font-size: 0.7rem; color: #8aaac8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.word-display { font-size: 2.5rem; font-weight: 600; color: #000; text-shadow: 0 4px 12px rgba(0,0,0,0.3); cursor: pointer; user-select: none; animation: fadeSlide 0.3s ease-out; }
.word-display:hover { text-shadow: 0 0 20px rgba(255,255,255,0.2); }

@keyframes fadeSlide { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }

#imageContainer { text-align: center; margin-bottom: -10px; }
#wordImage { max-width: 100%; max-height: 300px; width: auto; height: auto; border-radius: 16px; object-fit: contain; background: #fff; display: inline-block; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1 1 auto; min-height: 0; align-content: center; }

.option-btn { background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.08); border-radius: 40px; padding: 8px 4px; font-size: 1rem; font-weight: 500; color: #eef4fa; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.2); text-align: center; backdrop-filter: blur(4px); animation: fadeSlide 0.3s ease-out; animation-fill-mode: backwards; display: flex; align-items: center; justify-content: center; }
.option-btn:nth-child(1) { animation-delay: 0.05s; }
.option-btn:nth-child(2) { animation-delay: 0.10s; }
.option-btn:nth-child(3) { animation-delay: 0.15s; }
.option-btn:nth-child(4) { animation-delay: 0.20s; }
.option-btn:nth-child(5) { animation-delay: 0.25s; }
.option-btn:nth-child(6) { animation-delay: 0.30s; }
.option-btn:hover:not(:disabled) { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.3); transform: scale(1.02); }
.option-btn:active:not(:disabled) { transform: scale(0.96); }
.option-btn:disabled { cursor: default; opacity: 0.6; }
.option-btn.correct { background: rgba(46,213,115,0.3); border-color: #2ed573; box-shadow: 0 0 16px rgba(46,213,115,0.2); transform: scale(1.02); }
.option-btn.wrong { background: rgba(255,71,87,0.3); border-color: #ff4757; box-shadow: 0 0 16px rgba(255,71,87,0.2); animation: shake 0.3s; }

@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.option-btn.reveal-correct { background: rgba(46,213,115,0.15); border-color: #2ed573; }

.history-bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 10px; color: #b0c9e0; font-size: 0.8rem; flex-shrink: 0; }
.history-bar button { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); border-radius: 30px; padding: 2px 10px; color: #fff; font-size: 0.9rem; cursor: pointer; transition: 0.2s; }
.history-bar button:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.history-bar button:disabled { opacity: 0.3; cursor: default; }
.history-bar .history-text { min-width: 120px; text-align: center; background: rgba(0,0,0,0.2); padding: 2px 10px; border-radius: 30px; color: #e8edf5; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.action-row { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; flex-shrink: 0; margin-top: auto; padding-top: 0px; }
.action-btn { flex: 0 1 auto; padding: 6px 12px; border: none; border-radius: 30px; font-size: 0.8rem; font-weight: 600; color: #fff; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.3); display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); }
.action-btn:hover { transform: scale(1.04); background: rgba(255,255,255,0.18); }
.action-btn.reset { background: linear-gradient(135deg, #e67e22, #d35400); }
.action-btn.online { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.action-btn.leaderboard { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.action-btn.game-invites { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.action-btn.learn { background: linear-gradient(135deg, #9b59b6, #8e44ad); }

/* MODALS */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s; }
.modal-overlay.active { display: flex; }
#gameModeModal { z-index: 1200; }

@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

.modal { background: #1e3a5a; border-radius: 32px; padding: 28px 24px 32px; max-width: 500px; width: 95%; text-align: center; color: #fff; box-shadow: 0 24px 48px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); animation: scaleUp 0.3s ease-out; max-height: 90vh; overflow-y: auto; }

@keyframes scaleUp { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }

.modal h2 { font-size: 1.6rem; margin-bottom: 6px; }
.modal .result-stats { font-size: 1.1rem; margin: 12px 0; line-height: 1.6; }
.modal .result-stats span { font-weight: 700; color: #ffd93d; }
.modal .restart-btn { background: linear-gradient(135deg, #2ed573, #1e8c4a); border: none; border-radius: 40px; padding: 10px 20px; font-size: 1rem; font-weight: 600; color: #fff; cursor: pointer; transition: 0.2s; margin-top: 6px; box-shadow: 0 4px 12px rgba(46,213,115,0.3); }
.modal .restart-btn:hover { transform: scale(1.03); }

.auth-modal input { display: block; width: 100%; margin: 6px 0; padding: 10px; border-radius: 40px; border: none; background: rgba(255,255,255,0.1); color: #fff; font-size: 0.95rem; outline: none; }
.auth-modal input::placeholder { color: #b0c9e0; }
.auth-modal button[type="submit"] { margin-top: 4px; }

.user-list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); text-align: left; }
.user-list-item .online-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.online-indicator.online { background: #2ecc71; }
.online-indicator.offline { background: #7f8c8d; }

.invite-btn { background: rgba(46,204,113,0.3); border: 1px solid #2ecc71; border-radius: 20px; padding: 4px 12px; color: #fff; font-size: 0.8rem; cursor: pointer; transition: 0.2s; white-space: nowrap; }
.invite-btn:hover { background: rgba(46,204,113,0.6); }

.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 10px; }
.leaderboard-table th { text-align: left; padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); color: #8aaac8; }
.leaderboard-table td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* GAME OVER */
.game-over-content { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.trophy-icon { font-size: 3.5rem; color: #ffd93d; filter: drop-shadow(0 0 10px rgba(255,217,61,0.5)); margin-bottom: 5px; animation: bounce 2s infinite; }

@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.winner-name { font-size: 1.5rem; font-weight: 700; color: #fff; margin: 5px 0; }
.score-board { display: flex; justify-content: center; align-items: center; gap: 20px; width: 100%; margin: 15px 0; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 16px; }
.player-result { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 80px; }
.player-result.winner { transform: scale(1.1); }
.player-result.winner .p-name { color: #ffd93d; font-weight: bold; }
.p-name { font-size: 0.9rem; color: #b0c9e0; word-break: break-word; max-width: 120px; }
.p-score { font-size: 2rem; font-weight: 700; color: #fff; }

/* LEARN LIST */
.learn-list { max-height: 300px; overflow-y: auto; text-align: left; margin-top: 10px; padding-right: 5px; }
.learn-list::-webkit-scrollbar { width: 6px; }
.learn-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
.learn-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.learn-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; margin-bottom: 8px; background: rgba(255,255,255,0.05); border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); }
.learn-item > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.learn-word { font-weight: bold; color: #4fc3f7; font-size: 1rem; }
.learn-trans { color: #b0c9e0; font-size: 0.85rem; }
.learn-remove { background: rgba(231,76,60,0.2); border: 1px solid #e74c3c; color: #fff; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.learn-remove:hover { background: rgba(231,76,60,0.5); }

/* CHART */
.chart-container { width: 100%; height: 200px; margin: 15px 0; position: relative; }

/* RESPONSIVE */
@media (max-width: 600px) {
    .game-container { padding: 8px 10px; }
    h1 { font-size: 1.2rem; }
    .user-area { font-size: 0.75rem; padding: 2px 8px; }
    .stats { gap: 6px; font-size: 0.9rem; flex-wrap: wrap; justify-content: center; }
    .stats span i { width: 14px; font-size: 0.7rem; }
    .timer { font-size: 1.9rem; min-width: 40px; padding: 0 8px; }
    .settings-row { gap: 5px; padding: 10px 0px; flex-wrap: wrap; justify-content: center; }
    .setting-item { font-size: 0.7rem; }
    .setting-item i { font-size: 0.7rem; width: 16px; }
    .setting-item select, .setting-item .dir-switch { font-size: 0.8rem; height: 20px; padding: 1px 4px; }
    .setting-item .dir-switch label { font-size: 0.8rem; line-height: 18px; padding: 0 4px; }
    .setting-item .icon-btn { font-size: 0.7rem; padding: 1px 6px; height: 20px; }
    .word-display { font-size: 2rem; }
    #wordImage { max-height: 300px; }
    .option-btn { font-size: 1.1rem; padding: 8px 4px; }
    .history-bar .history-text { min-width: 80px; font-size: 0.9rem; }
    .action-btn { font-size: 0.8rem; padding: 4px 8px; }
    .modal { padding: 20px 16px 24px; }
    .score-board { gap: 10px; padding: 10px; }
    .p-score { font-size: 1.5rem; }
    .winner-name { font-size: 1.2rem; }
}