/**
 * Race Game Styles v2.0
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 420px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    flex: 1;
}

.screen.active {
    display: flex;
}

/* Language Selector */
.lang-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
}

.lang-btn {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid #333;
    background: rgba(255,255,255,0.05);
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn.active {
    border-color: #ffd700;
    background: rgba(255,215,0,0.2);
    color: #ffd700;
}

/* Logo */
.game-logo {
    text-align: center;
    margin: 15px 0;
}

.game-logo h1 {
    font-size: 28px;
    text-shadow: 0 0 20px rgba(255,107,107,0.8);
}

.game-logo .subtitle {
    color: #888;
    font-size: 14px;
    margin-top: 5px;
}

.car-preview {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    font-size: 40px;
}

/* Mode Selector */
.mode-selector {
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    padding: 15px;
    margin: 10px 0;
}

.mode-label {
    color: #888;
    font-size: 12px;
    text-align: center;
    margin-bottom: 10px;
}

.mode-buttons {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #333;
    background: rgba(255,255,255,0.05);
    color: #888;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.mode-btn.active {
    border-color: #4ecdc4;
    background: rgba(78,205,196,0.2);
    color: #4ecdc4;
}

.mode-btn .mode-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}

.mode-preview {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.preview-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.preview-num {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu Buttons */
.menu-btn {
    width: 100%;
    padding: 16px;
    margin: 6px 0;
    border: none;
    border-radius: 15px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

.menu-btn:active {
    transform: scale(0.98);
}

.btn-create {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
}

.btn-join {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.btn-solo {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-help {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.btn-reset {
    background: rgba(255,255,255,0.1);
    color: #888;
    font-size: 13px;
    padding: 12px;
    margin-top: auto;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #1e1e3f;
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 320px;
}

.modal-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}

.code-input {
    width: 100%;
    padding: 15px;
    font-size: 24px;
    text-align: center;
    background: rgba(255,255,255,0.1);
    border: 2px solid #333;
    border-radius: 12px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 8px;
    font-family: monospace;
}

.code-input:focus {
    outline: none;
    border-color: #4ecdc4;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.modal-btn.cancel {
    background: rgba(255,255,255,0.1);
    color: #888;
}

.modal-btn.confirm {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.error-message {
    background: rgba(255,107,107,0.2);
    color: #ff6b6b;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    margin: 10px 0;
    font-size: 14px;
}

/* Help Modal */
.help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.help-modal.active {
    display: flex;
}

.help-content {
    background: #1e1e3f;
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 380px;
    margin: auto;
}

.help-title {
    text-align: center;
    font-size: 20px;
    margin-bottom: 15px;
    color: #ffd700;
}

.help-section {
    margin: 12px 0;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

.help-section h3 {
    color: #4ecdc4;
    font-size: 14px;
    margin-bottom: 8px;
}

.help-section p,
.help-section li {
    color: #ccc;
    font-size: 13px;
    line-height: 1.7;
}

.help-section ul,
.help-section ol {
    padding-left: 18px;
    margin: 0;
}

.help-close {
    width: 100%;
    padding: 14px;
    margin-top: 15px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
}

/* Waiting Room */
.room-code-box {
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin: 15px 0;
}

.room-code-label {
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
}

.room-code {
    color: #ffd700;
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 8px;
    font-family: monospace;
}

.mode-info {
    margin-top: 12px;
    padding: 6px 16px;
    background: rgba(78,205,196,0.2);
    border-radius: 15px;
    display: inline-block;
    color: #4ecdc4;
    font-size: 13px;
}

.mode-info.angka {
    background: rgba(102,126,234,0.2);
    color: #667eea;
}

.players-box {
    margin: 15px 0;
}

.player-slot {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid transparent;
}

.player-slot.ready {
    border-color: #4ecdc4;
}

.player-slot.waiting {
    border: 2px dashed #444;
}

.player-slot.joined {
    border-color: #ffd700;
}

.player-car {
    font-size: 32px;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: bold;
    font-size: 15px;
}

.player-status {
    color: #4ecdc4;
    font-size: 11px;
    margin-top: 2px;
}

.player-status.waiting {
    color: #888;
}

.rules-box {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 12px;
    margin: 10px 0;
}

.rules-title {
    color: #888;
    font-size: 11px;
    text-align: center;
    margin-bottom: 8px;
}

.rules-list {
    color: #aaa;
    font-size: 12px;
    line-height: 1.7;
}

.btn-start {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 15px;
    font-size: 15px;
    font-weight: bold;
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    cursor: pointer;
    margin-top: auto;
}

.btn-start:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Countdown */
.countdown-number {
    font-size: 150px;
    font-weight: bold;
    text-shadow: 0 0 60px rgba(255,107,107,0.8);
    animation: pulse 1s ease-in-out;
}

.countdown-number.go {
    font-size: 70px;
    color: #4ecdc4;
    text-shadow: 0 0 60px rgba(78,205,196,0.8);
}

@keyframes pulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.countdown-text {
    color: #888;
    font-size: 16px;
    margin-top: 15px;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.game-title {
    font-size: 15px;
    font-weight: bold;
}

.mode-badge {
    background: rgba(78,205,196,0.2);
    color: #4ecdc4;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
}

.mode-badge.angka {
    background: rgba(102,126,234,0.2);
    color: #667eea;
}

.round-info {
    color: #ffd700;
    font-size: 13px;
}

/* Race Track */
.race-track-container {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
}

.track-labels {
    display: flex;
    justify-content: space-between;
    color: #666;
    font-size: 9px;
    margin-bottom: 6px;
}

.race-track {
    height: 40px;
    background: linear-gradient(90deg, #1a1a2e 0%, #2a2a4e 50%, #1a1a2e 100%);
    border-radius: 20px;
    position: relative;
    margin: 8px 0;
    border: 2px solid #333;
    overflow: hidden;
}

.race-track.you {
    border-color: #4ecdc4;
}

.race-track.opponent {
    border-color: #ff6b6b;
}

.track-progress {
    height: 100%;
    border-radius: 20px;
    transition: width 0.3s ease-out;
    position: relative;
    min-width: 45px;
}

.track-progress.you {
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
}

.track-progress.opponent {
    background: linear-gradient(90deg, #ff6b6b, #ee5a5a);
}

.car-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
}

.track-percentage {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.finish-flag {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

/* Target Box */
.target-box {
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin: 10px 0;
    border: 3px solid #333;
    transition: all 0.2s;
}

.target-box.correct {
    border-color: #4ecdc4;
    background: rgba(78,205,196,0.15);
}

.target-box.wrong {
    border-color: #ff6b6b;
    background: rgba(255,107,107,0.15);
}

.target-label {
    color: #888;
    font-size: 14px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.target-color {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    margin: 0 auto;
    border: 4px solid rgba(255,255,255,0.3);
}

.target-color.biru {
    background: #3498db;
    box-shadow: 0 0 25px rgba(52,152,219,0.5);
}

.target-color.merah {
    background: #e74c3c;
    box-shadow: 0 0 25px rgba(231,76,60,0.5);
}

.target-color.kuning {
    background: #f1c40f;
    box-shadow: 0 0 25px rgba(241,196,15,0.5);
}

.target-color.putih {
    background: #ecf0f1;
    box-shadow: 0 0 25px rgba(236,240,241,0.5);
}

.target-number {
    width: 90px;
    height: 90px;
    border-radius: 18px;
    margin: 0 auto;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 4px solid rgba(255,255,255,0.3);
    box-shadow: 0 0 25px rgba(102,126,234,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
}

.target-name {
    font-size: 20px;
    font-weight: bold;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Color Buttons */
.color-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: auto;
    padding: 8px 0;
}

.color-btn {
    aspect-ratio: 1;
    border-radius: 12px;
    border: 3px solid rgba(255,255,255,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.1s;
}

.color-btn:active {
    transform: scale(0.95);
}

.color-btn.biru { background: #3498db; }
.color-btn.merah { background: #e74c3c; }
.color-btn.kuning { background: #f1c40f; }
.color-btn.putih { background: #ecf0f1; }

.color-btn .btn-label {
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-top: 4px;
}

.color-btn.putih .btn-label {
    color: #333;
    text-shadow: none;
}

.color-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Number Buttons */
.number-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: auto;
    padding: 8px 0;
}

.number-btn {
    aspect-ratio: 1;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.2);
    background: linear-gradient(135deg, #2a2a4a, #1a1a3a);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.1s;
}

.number-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.number-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Result Screen */
.result-title {
    text-align: center;
    margin: 25px 0 15px 0;
}

.result-title .trophy {
    font-size: 60px;
    display: block;
    margin-bottom: 8px;
}

.result-title h2 {
    font-size: 28px;
}

.result-title.win h2 {
    color: #4ecdc4;
}

.result-title.lose h2 {
    color: #ff6b6b;
}

.final-score {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

.score-card {
    text-align: center;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    min-width: 110px;
}

.score-card.winner {
    border: 2px solid #4ecdc4;
}

.score-card .car-emoji {
    font-size: 30px;
}

.score-card .score-label {
    color: #888;
    font-size: 11px;
    margin-top: 6px;
}

.score-card .score-progress {
    font-size: 22px;
    font-weight: bold;
    margin-top: 4px;
}

.stats-box {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 15px;
    margin: 12px 0;
}

.stats-title {
    color: #888;
    font-size: 11px;
    text-align: center;
    margin-bottom: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #888;
    font-size: 13px;
}

.stat-value {
    font-weight: bold;
    font-size: 13px;
}

.stat-value.green {
    color: #4ecdc4;
}

.stat-value.red {
    color: #ff6b6b;
}

.result-buttons {
    margin-top: auto;
    padding: 8px 0;
}

.result-btn {
    width: 100%;
    padding: 14px;
    margin: 6px 0;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.btn-rematch {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.5);
    border: none;
    padding: 8px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    z-index: 50;
}

.footer-text {
    text-align: center;
    color: #444;
    font-size: 10px;
    padding: 8px;
    margin-top: auto;
}
