* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
}

.container {
    max-width: 480px;
    width: 100%;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #94a3b8;
    margin-bottom: 2rem;
}

.hidden {
    display: none !important;
}

.screen {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.name-input {
    margin-bottom: 1.5rem;
}

.name-input label {
    display: block;
    margin-bottom: 0.5rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

.name-input input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 2px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.name-input input:focus {
    border-color: #f59e0b;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

#games-list {
    margin-top: 2.5rem;
    text-align: left;
}

#games-list h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.muted {
    color: #64748b;
    font-size: 0.875rem;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #334155;
}

.game-item .creator {
    font-weight: 500;
}

.btn-join {
    background: #1e293b;
    color: #f59e0b;
    border: 2px solid #f59e0b;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
}

.btn-join:hover:not(:disabled) {
    background: #f59e0b;
    color: #0f172a;
}

.waiting-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #334155;
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.scoreboard {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.player-name {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.score {
    font-size: 2.5rem;
    font-weight: 800;
    color: #f59e0b;
}

.vs {
    font-size: 0.875rem;
    color: #475569;
    text-transform: uppercase;
    font-weight: 600;
}

.round-info {
    font-size: 1rem;
    color: #94a3b8;
    margin-bottom: 1.5rem;
}

.guess-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn-guess {
    flex: 1;
    max-width: 160px;
    padding: 1.25rem;
    font-size: 1.25rem;
    background: #1e293b;
    color: #e2e8f0;
    border: 2px solid #334155;
}

.btn-guess:hover:not(:disabled) {
    border-color: #f59e0b;
    color: #f59e0b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.coin-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1rem 0;
}

.coin-label {
    font-size: 0.875rem;
    color: #94a3b8;
}

.coin-value {
    font-size: 2rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #f59e0b;
    margin-top: 0.25rem;
}

#round-outcome {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

#rounds-history {
    margin-top: 2rem;
    text-align: left;
}

#rounds-history h3 {
    font-size: 1rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
}

.history-round {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    border-radius: 0.375rem;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    border: 1px solid #334155;
}

.history-round .round-num {
    color: #64748b;
    min-width: 50px;
}

.history-round .coin {
    color: #f59e0b;
    font-weight: 600;
    text-transform: capitalize;
    min-width: 60px;
    text-align: center;
}

.history-round .result-correct {
    color: #22c55e;
}

.history-round .result-wrong {
    color: #ef4444;
}

.result-message {
    font-size: 2rem;
    font-weight: 800;
    margin: 2rem 0 1.5rem;
}

.result-win {
    color: #22c55e;
}

.result-lose {
    color: #ef4444;
}

.result-tie {
    color: #f59e0b;
}

.final-scores {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.final-score span:first-child {
    color: #94a3b8;
    font-size: 0.875rem;
}

#chat-panel {
    margin-top: 2rem;
    text-align: left;
    border-top: 1px solid #334155;
    padding-top: 1rem;
}

#chat-panel h3 {
    font-size: 1rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
}

#chat-messages {
    height: 160px;
    overflow-y: auto;
    background: #1e293b;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-msg {
    font-size: 0.875rem;
    line-height: 1.4;
}

.chat-msg .chat-name {
    font-weight: 600;
    color: #f59e0b;
}

.chat-msg.chat-mine .chat-name {
    color: #38bdf8;
}

#chat-form {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #334155;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.875rem;
    outline: none;
}

#chat-input:focus {
    border-color: #f59e0b;
}

.btn-send {
    background: #334155;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-send:hover {
    background: #475569;
}

/* Age gate */

#kid-iframe-container {
    width: 100%;
    min-height: 480px;
}

#kid-iframe-container iframe {
    width: 100%;
    height: 600px;
    max-height: calc(100vh - 200px);
    border: none;
    border-radius: 0.5rem;
}

#age-gate-loading {
    padding: 2rem 0;
}

/* Chat disabled state */

.chat-disabled #chat-form {
    display: none;
}

.chat-disabled #chat-messages {
    display: none;
}

.chat-disabled::after {
    content: "Chat is not available for your account.";
    display: block;
    color: #64748b;
    font-size: 0.875rem;
    padding: 1rem 0;
}
