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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #0a0a1a;
    color: #e0e0e0;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.screen {
    display: none;
    min-height: 100dvh;
    padding: 20px;
}
.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu */
.menu-container {
    text-align: center;
    max-width: 360px;
    width: 100%;
}

.title {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    background: linear-gradient(135deg, #ff6b35, #f7c948, #ff6b35);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.subtitle {
    color: #888;
    font-size: 1rem;
    margin-bottom: 48px;
    letter-spacing: 0.1em;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

button {
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid #333;
    border-radius: 12px;
    background: #151525;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
button:hover {
    background: #1e1e35;
    border-color: #ff6b35;
    color: #fff;
}
button:active {
    transform: scale(0.97);
}
button:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

/* How to Play */
.how-to-play-container {
    max-width: 500px;
    width: 100%;
}
.how-to-play-container h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #f7c948;
}
.rules {
    background: #151525;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    line-height: 1.7;
}
.rules h3 {
    color: #ff6b35;
    margin: 16px 0 8px;
}
.rules ul {
    padding-left: 20px;
}
.rules li {
    margin: 6px 0;
}

/* Join */
.join-container {
    text-align: center;
    max-width: 360px;
    width: 100%;
}
.join-container h2 {
    margin-bottom: 24px;
    color: #f7c948;
}
.divider {
    color: #555;
    margin: 16px 0;
    font-size: 0.9rem;
}
#room-input {
    width: 100%;
    padding: 14px;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    background: #151525;
    border: 2px solid #333;
    border-radius: 12px;
    color: #e0e0e0;
    margin-bottom: 12px;
    outline: none;
}
#room-input:focus {
    border-color: #ff6b35;
}
.back-btn {
    margin-top: 16px;
    background: transparent;
    border-color: #555;
    color: #888;
}

/* Waiting */
.waiting-container {
    text-align: center;
}
.waiting-container h2 {
    margin-bottom: 24px;
    color: #f7c948;
}
.room-code-display {
    margin-bottom: 24px;
}
.room-code-display .code {
    display: block;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.4em;
    color: #ff6b35;
    margin-top: 8px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}
.spinner.small {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Handoff */
.handoff-container {
    text-align: center;
}
.handoff-container h2 {
    font-size: 2rem;
    color: #f7c948;
    margin-bottom: 12px;
}
.handoff-container p {
    color: #888;
    margin-bottom: 32px;
}

/* Game */
.game-container {
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
}

.scoreboard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #151525;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}
.score-side {
    text-align: center;
    min-width: 70px;
}
.score-label {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.score-value {
    font-size: 2.2rem;
    font-weight: 900;
}
.p1-side .score-value { color: #4ecdc4; }
.p2-side .score-value { color: #ff6b6b; }

.score-center {
    text-align: center;
}
#round-number {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ccc;
}
.cards-left {
    font-size: 0.75rem;
    color: #666;
}

/* Selection */
.selection-area {
    margin-bottom: 20px;
}
.select-group {
    margin-bottom: 16px;
}
.select-group h3 {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}
.number-row {
    display: flex;
    gap: 8px;
}
.num-btn {
    flex: 1;
    aspect-ratio: 1;
    font-size: 1.5rem;
    font-weight: 800;
    border: 2px solid #2a2a40;
    border-radius: 12px;
    background: #151525;
    color: #999;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
}
.num-btn .num-val {
    line-height: 1;
}
.num-btn .num-count {
    font-size: 0.6rem;
    font-weight: 600;
    color: #555;
    line-height: 1;
}
.num-btn.exhausted {
    opacity: 0.25;
    cursor: default;
}
.num-btn.exhausted:hover {
    border-color: #2a2a40;
    color: #999;
}
.num-btn:hover:not(.exhausted) {
    border-color: #444;
    color: #ccc;
}
.num-btn.selected {
    border-color: #ff6b35;
    background: #2a1a10;
    color: #ff6b35;
}

#action-row .num-btn.selected {
    border-color: #4ecdc4;
    background: #0a2520;
    color: #4ecdc4;
}
#call-row .num-btn.selected {
    border-color: #f7c948;
    background: #2a2510;
    color: #f7c948;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    background: #1a1a30;
    border-color: #333;
    margin-bottom: 16px;
}
.submit-btn:not(:disabled) {
    background: linear-gradient(135deg, #ff6b35, #e85d26);
    border-color: #ff6b35;
    color: #fff;
}

.waiting-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    color: #888;
    font-size: 0.9rem;
}

/* Round History */
.round-history {
    margin-top: 8px;
}
.round-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #12121f;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.round-entry .round-num {
    color: #555;
    font-weight: 700;
    width: 24px;
}
.round-entry .round-moves {
    color: #888;
    flex: 1;
    text-align: center;
}
.round-entry .round-pts {
    font-weight: 700;
    width: 70px;
    text-align: right;
}
.round-entry .pts-p1 { color: #4ecdc4; }
.round-entry .pts-p2 { color: #ff6b6b; }

.compact .round-entry {
    padding: 6px 10px;
    font-size: 0.78rem;
}

/* Result Screen */
.result-container {
    text-align: center;
    max-width: 440px;
    width: 100%;
}

.result-matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
}
.result-player {
    background: #151525;
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 130px;
}
.result-player-label {
    display: block;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.result-moves {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.result-action {
    font-size: 2.5rem;
    font-weight: 900;
    color: #4ecdc4;
}
.result-call-label {
    font-size: 0.7rem;
    color: #555;
    text-transform: uppercase;
}
.result-call {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f7c948;
}
.vs {
    font-size: 1rem;
    font-weight: 800;
    color: #444;
}

.result-outcome {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    min-height: 2em;
}
.result-outcome.catch { color: #4ecdc4; }
.result-outcome.caught { color: #ff6b6b; }
.result-outcome.double { color: #f7c948; }
.result-outcome.clash { color: #aaa; }

.result-points {
    display: flex;
    justify-content: center;
    gap: 60px;
    margin-bottom: 28px;
    font-size: 1.3rem;
    font-weight: 800;
}
.result-points span:first-child { color: #4ecdc4; }
.result-points span:last-child { color: #ff6b6b; }

/* Game Over */
.gameover-container {
    text-align: center;
    max-width: 440px;
    width: 100%;
}
.gameover-container h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}
.final-score {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 24px;
}
.final-score span:first-child { color: #4ecdc4; }
.final-score span:last-child { color: #ff6b6b; }

.gameover-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.gameover-buttons button {
    flex: 1;
}

/* Create Room / Hand Config */
.create-room-container {
    text-align: center;
    max-width: 360px;
    width: 100%;
}
.create-room-container h2 {
    margin-bottom: 8px;
    color: #f7c948;
}
.config-subtitle {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.config-values-section {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
}
.config-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    white-space: nowrap;
}
#config-values-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 1rem;
    background: #151525;
    border: 2px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    outline: none;
    text-align: center;
}
#config-values-input:focus {
    border-color: #ff6b35;
}
.config-apply-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
}
.hand-config {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.hand-config-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.config-card {
    font-size: 1.4rem;
    font-weight: 800;
    color: #4ecdc4;
    width: 36px;
    text-align: center;
}
.config-minus, .config-plus {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}
.config-count {
    font-size: 1.3rem;
    font-weight: 700;
    width: 32px;
    text-align: center;
}
.config-total {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

@media (max-width: 400px) {
    .title { font-size: 3rem; }
    .num-btn { font-size: 1.2rem; border-radius: 10px; }
    .result-matchup { gap: 12px; }
    .result-player { padding: 12px 14px; min-width: 110px; }
    .result-action { font-size: 2rem; }
}
