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

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-panel: #0f3460;
    --accent-green: #4ecca3;
    --accent-purple: #9b59b6;
    --accent-blue: #3498db;
    --accent-orange: #e67e22;
    --accent-red: #e74c3c;
    --accent-yellow: #f1c40f;
    --text-primary: #ecf0f1;
    --text-secondary: #95a5a6;
    --text-dim: #5a6a7a;
    --border-color: #2c3e50;
    --pixel-font: 'Press Start 2P', monospace;
    --shadow-glow: 0 0 20px rgba(78, 204, 163, 0.3);
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    display: none;
    position: fixed;
    inset: 0;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden { display: none !important; }

.game-title {
    font-family: var(--pixel-font);
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    text-align: center;
    color: var(--accent-green);
    text-shadow: 0 0 20px rgba(78, 204, 163, 0.5), 3px 3px 0 #0a0a1a;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.game-subtitle {
    font-family: var(--pixel-font);
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

.menu-container, .lobby-container {
    width: 90%;
    max-width: 600px;
    padding: 2rem;
}

.btn {
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    border: 2px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.btn-primary {
    background: var(--accent-green);
    color: #0a0a1a;
    border-color: #3ba882;
    box-shadow: 0 4px 0 #2d8068, var(--shadow-glow);
}

.btn-primary:hover {
    background: #5fd9b3;
    box-shadow: 0 4px 0 #2d8068, 0 0 30px rgba(78, 204, 163, 0.5);
}

.btn-primary:active {
    box-shadow: 0 1px 0 #2d8068;
    transform: translateY(3px) scale(0.98);
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 0 #1a5276;
}

.btn-secondary:hover {
    background: #154a80;
}

.btn-secondary:active {
    box-shadow: 0 1px 0 #1a5276;
    transform: translateY(3px) scale(0.98);
}

.btn-large {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    margin-bottom: 0.8rem;
    border-radius: 4px;
}

.btn-option {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-color);
    padding: 0.6rem 0.8rem;
    font-size: 0.55rem;
    border-radius: 3px;
}

.btn-option.active {
    background: var(--accent-purple);
    color: white;
    border-color: #8e44ad;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.4);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-panel {
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    animation: slideIn 0.3s ease;
}

.form-panel h2 {
    font-family: var(--pixel-font);
    font-size: 0.8rem;
    color: var(--accent-yellow);
    margin-bottom: 1.2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"] {
    width: 100%;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(78, 204, 163, 0.2);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

.grid-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.game-code-display {
    text-align: center;
    margin: 1.5rem 0;
}

.game-code-display .label {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.game-code-display .code {
    font-family: var(--pixel-font);
    font-size: 2rem;
    color: var(--accent-yellow);
    letter-spacing: 0.3em;
    text-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.code-copyable {
    cursor: pointer;
    transition: transform 0.15s;
}

.code-copyable:hover {
    transform: scale(1.05);
}

.code-copyable:active {
    transform: scale(0.95);
}

.copy-toast {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--accent-green);
    margin-top: 0.5rem;
    animation: slideIn 0.3s ease;
}

.game-list-section {
    margin-top: 1.2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.game-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.game-list-header label {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-secondary);
}

.btn-refresh {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.btn-refresh:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.game-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.game-list-empty {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--text-dim);
    text-align: center;
    padding: 1rem 0;
}

.game-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    animation: slideIn 0.3s ease;
}

.game-list-item:hover {
    border-color: var(--accent-green);
    background: rgba(78, 204, 163, 0.05);
}

.game-list-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.game-list-item-code {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--accent-yellow);
    letter-spacing: 0.1em;
}

.game-list-item-details {
    font-family: var(--pixel-font);
    font-size: 0.35rem;
    color: var(--text-secondary);
}

.game-list-item-players {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--accent-green);
    white-space: nowrap;
}

.lobby-players {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin: 1.5rem 0;
}

.lobby-player {
    background: var(--bg-card);
    border: 2px solid var(--accent-green);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    animation: slideIn 0.3s ease;
}

.lobby-player .avatar {
    font-size: 1.5rem;
}

.lobby-waiting {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-align: center;
    animation: pulse 1.5s ease infinite;
}

.lobby-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    margin: 1rem auto;
    animation: spin 1s linear infinite;
}

.game-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

.game-area {
    flex: 7;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.5rem;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.turn-indicator {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    background: var(--accent-green);
    color: #0a0a1a;
    transition: all 0.3s ease;
    white-space: nowrap;
    animation: turnPulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(78, 204, 163, 0.6), 0 0 40px rgba(78, 204, 163, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.turn-indicator.not-my-turn {
    background: var(--bg-panel);
    color: var(--text-primary);
    font-size: 0.6rem;
    animation: none;
    box-shadow: none;
    border-color: var(--border-color);
    text-shadow: none;
}

.game-timer {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    white-space: nowrap;
}

@keyframes turnPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(78, 204, 163, 0.6), 0 0 40px rgba(78, 204, 163, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(78, 204, 163, 0.8), 0 0 60px rgba(78, 204, 163, 0.4); }
}

.game-title-small {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-dim);
    display: none;
}

@media (min-width: 800px) {
    .game-title-small { display: block; }
}

.game-code-badge {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--accent-yellow);
    background: rgba(241, 196, 15, 0.1);
    border: 1px solid rgba(241, 196, 15, 0.3);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    letter-spacing: 0.15em;
    white-space: nowrap;
    cursor: pointer;
}

.score-display {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    display: flex;
    gap: 0.8rem;
}

.score-display .score-item {
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    background: var(--bg-panel);
    transition: transform 0.2s;
}

.score-display .score-item.active {
    border: 1px solid var(--accent-green);
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.player-stacks {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem;
    flex-shrink: 0;
}

.player-stack {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    position: relative;
    transition: all 0.3s ease;
}

.player-stack.active-turn {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(78, 204, 163, 0.4), 0 0 30px rgba(78, 204, 163, 0.2);
    background: rgba(78, 204, 163, 0.08);
    animation: stackPulse 1.5s ease-in-out infinite;
}

@keyframes stackPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(78, 204, 163, 0.4), 0 0 30px rgba(78, 204, 163, 0.2); }
    50% { box-shadow: 0 0 25px rgba(78, 204, 163, 0.6), 0 0 50px rgba(78, 204, 163, 0.3); }
}

.player-stack .stack-cards {
    display: flex;
    margin-left: 0.3rem;
}

.player-stack .mini-card {
    width: 16px;
    height: 20px;
    background: linear-gradient(to bottom, #4a8c3f 20%, #8B6914 20%, #7a5c12 100%);
    border: 1px solid #5a3a0a;
    border-radius: 2px;
    margin-left: -6px;
    image-rendering: pixelated;
}

.player-stack .mini-card:first-child {
    margin-left: 0;
}

.player-stack .stack-count {
    color: var(--accent-yellow);
    min-width: 1.5em;
    text-align: center;
    transition: transform 0.2s;
}

.player-stack .stack-count.bounce {
    animation: bounceScale 0.4s ease;
}

.chat-panel {
    flex: 3;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-left: 2px solid var(--border-color);
    min-width: 0;
}

.chat-header {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chat-msg {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    background: rgba(15, 52, 96, 0.4);
    font-size: 0.8rem;
    animation: msgSlideIn 0.25s ease;
    word-break: break-word;
}

.chat-msg .msg-name {
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--accent-blue);
    margin-bottom: 0.2rem;
}

.chat-msg .msg-text {
    color: var(--text-primary);
    line-height: 1.3;
}

.chat-msg .msg-translations {
    margin-top: 0.25rem;
    padding-top: 0.2rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.chat-msg .msg-translation {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.3;
    margin-top: 0.1rem;
}

.chat-msg .msg-translation .flag {
    font-size: 0.8rem;
    margin-right: 0.2rem;
}

.chat-input-area {
    display: flex;
    padding: 0.5rem;
    gap: 0.3rem;
    border-top: 2px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    font-size: 0.85rem;
    border-radius: 4px;
    outline: none;
    min-width: 0;
}

.chat-input-area input:focus {
    border-color: var(--accent-blue);
}

.btn-chat-send {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 0.5rem 0.8rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-chat-send:active {
    transform: scale(0.9);
}

.btn-give-up {
    background: rgba(231, 76, 60, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(231, 76, 60, 0.4);
    padding: 0.3rem 0.5rem;
    font-size: 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    text-transform: none;
    letter-spacing: 0;
}

.btn-give-up:hover {
    background: rgba(231, 76, 60, 0.3);
}

.gameover-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

.gameover-container {
    flex: 7;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.winner-spotlight {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0.3);
}

.winner-spotlight.visible {
    animation: spotlightIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes spotlightIn {
    0% { opacity: 0; transform: scale(0.3) translateY(40px); }
    60% { opacity: 1; transform: scale(1.1) translateY(-5px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.winner-crown {
    font-size: 3rem;
    opacity: 0;
    filter: drop-shadow(0 0 15px rgba(241, 196, 15, 0.8));
}

.winner-crown.visible {
    animation: crownDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes crownDrop {
    0% { opacity: 0; transform: translateY(-60px) rotate(-20deg); }
    60% { opacity: 1; transform: translateY(5px) rotate(5deg); }
    80% { transform: translateY(-3px) rotate(-2deg); }
    100% { opacity: 1; transform: translateY(0) rotate(0deg); }
}

.winner-avatar {
    font-size: 5rem;
    line-height: 1;
    margin: 0.3rem 0;
    filter: drop-shadow(0 0 25px rgba(241, 196, 15, 0.6));
    animation: winnerGlow 2s ease-in-out infinite;
}

@keyframes winnerGlow {
    0%, 100% { filter: drop-shadow(0 0 25px rgba(241, 196, 15, 0.6)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 40px rgba(241, 196, 15, 0.9)) drop-shadow(0 0 60px rgba(78, 204, 163, 0.4)); transform: scale(1.05); }
}

.gameover-title-epic {
    font-size: clamp(1rem, 3.5vw, 2rem) !important;
    color: var(--accent-yellow) !important;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.8), 0 0 60px rgba(241, 196, 15, 0.4), 3px 3px 0 #0a0a1a !important;
    margin-top: 0.3rem;
}

.winner-score-label {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--accent-green);
    text-shadow: 0 0 10px rgba(78, 204, 163, 0.5);
    margin-top: 0.3rem;
    opacity: 0;
}

.winner-score-label.visible {
    animation: slideIn 0.5s ease forwards;
}

.gameover-scores {
    margin: 1.5rem 0;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 500px;
}

.gameover-time {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.gameover-score-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    border: 2px solid var(--border-color);
    opacity: 0;
    transform: translateY(20px);
}

.gameover-score-row.show {
    animation: scoreRowIn 0.4s ease forwards;
}

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

.gameover-score-row.winner {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.3);
    font-size: 0.8rem;
    padding: 1rem;
}

.gameover-score-row.loser {
    opacity: 0;
    color: var(--text-secondary);
    font-size: 0.6rem;
    border-color: rgba(44, 62, 80, 0.5);
    background: rgba(22, 33, 62, 0.5);
}

.gameover-score-row.loser.show {
    animation: scoreRowIn 0.4s ease forwards;
}

.gameover-score-row .rank {
    font-size: 1.2rem;
}

.gameover-score-row.loser .rank {
    font-size: 1rem;
    opacity: 0.7;
}

.gameover-buttons {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.rematch-notify {
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    color: var(--accent-green);
    text-align: center;
    padding: 0.6rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(78, 204, 163, 0.15);
    border: 2px solid var(--accent-green);
    border-radius: 8px;
    position: relative;
    z-index: 2;
    max-width: 400px;
    width: 100%;
}

.rematch-notify.visible {
    animation: rematchNotifyIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, rematchGlow 1.5s ease-in-out 0.5s infinite;
}

@keyframes rematchNotifyIn {
    0% { opacity: 0; transform: scale(0.5) translateY(20px); }
    60% { opacity: 1; transform: scale(1.1) translateY(-5px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes rematchGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(78, 204, 163, 0.3); border-color: var(--accent-green); }
    50% { box-shadow: 0 0 25px rgba(78, 204, 163, 0.6), 0 0 50px rgba(78, 204, 163, 0.2); border-color: var(--accent-yellow); }
}

.rematch-status {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--accent-yellow);
    text-align: center;
    padding: 0.4rem;
    animation: pulse 1.5s ease infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

@keyframes bounceScale {
    0% { transform: scale(1); }
    40% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

#screen-gameover.active {
    align-items: stretch;
    justify-content: stretch;
}

@media (max-height: 500px) {
    .game-header { padding: 0.2rem 0.5rem; }
    .player-stacks { padding: 0.3rem; gap: 0.5rem; }
}

.coin-flip-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 26, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.coin-flip-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.coin-flip-coin {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
}

.coin-flip-coin.spinning {
    animation: coinSpin 0.15s linear infinite;
}

.coin-flip-coin.spinning-slow {
    animation: coinSpin 0.4s ease-in-out infinite;
}

.coin-flip-coin.landing {
    animation: coinLand 0.6s ease-out forwards;
}

.coin-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    backface-visibility: hidden;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(241, 196, 15, 0.2), transparent);
}

.coin-back {
    transform: rotateY(180deg);
}

@keyframes coinSpin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

@keyframes coinLand {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.2); }
    70% { transform: rotateY(360deg) scale(1.1); }
    100% { transform: rotateY(360deg) scale(1); }
}

.coin-flip-result {
    font-family: var(--pixel-font);
    font-size: 0.9rem;
    color: var(--accent-yellow);
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.6);
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
}

.coin-flip-result.visible {
    animation: resultAppear 0.5s ease-out forwards;
}

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

@media (max-width: 600px) {
    .game-layout, .gameover-layout { flex-direction: column; }
    .game-area { flex: 1; }
    .gameover-container { flex: 1; }
    .chat-panel {
        flex: none;
        height: 200px;
        border-left: none;
        border-top: 2px solid var(--border-color);
    }
}

.special-sections {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.special-section {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
}

.special-section.disabled {
    opacity: 0.4;
}

.special-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.special-icon {
    font-size: 1.2rem;
}

.special-name {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-primary);
    flex: 1;
}

.special-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.special-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 20px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.special-toggle input:checked + .toggle-slider {
    background: var(--accent-green);
}

.special-toggle input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #0a0a1a;
}

.special-stepper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
    justify-content: center;
}

.btn-step {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 28px;
    height: 28px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
    text-transform: none;
    letter-spacing: 0;
}

.btn-step:hover {
    border-color: var(--accent-green);
    background: rgba(78, 204, 163, 0.1);
}

.btn-step:disabled {
    opacity: 0.3;
    cursor: default;
}

.step-value {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--accent-yellow);
    min-width: 2em;
    text-align: center;
}

.special-warning {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--accent-red);
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.5rem;
    text-align: center;
}
