@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --red: #ff0033;
    --accent: #ffcc00;
}

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

body {
    background: #0a0a0a;
    color: #fff;
    font-family: 'Press Start 2P', system-ui;
    min-height: 100vh;
    padding: 15px;
    line-height: 1.4;
}

/* Compact header on mobile */
header {
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 4px solid var(--red);
    padding-bottom: 10px;
}

h1 {
    font-size: 2.4rem;
    color: var(--red);
    text-shadow: 0 0 10px #ff0033;
    line-height: 2.4rem;
    letter-spacing: 1px;
    margin: 4px 0;
}

.tagline {
    font-size: 1rem;
    letter-spacing: 3px;
    color: var(--accent);
}

@media (max-width: 600px) {
    h1 { font-size: 2rem; }
    .tagline { font-size: 0.88rem; letter-spacing: 2px; }
}

/* Scores */
.scores {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: none;
}

.score-box {
    background: #1a1a1a;
    padding: 10px 25px;
    border: 3px solid var(--red);
    border-radius: 8px;
    min-width: 160px;
    text-align: center;
}

.player-label { color: #00ffcc; }
.ai-label { color: #ff9900; }

/* Play area */
#play-area {
    background: #1a1a1a;
    border: 4px dashed var(--red);
    border-radius: 12px;
    padding: 20px;
    min-height: 180px;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
}

.lead-card {
    display: inline-block;
    background: #222;
    border: 4px solid var(--accent);
    border-radius: 10px;
    padding: 15px;
    width: 260px;
    margin: 0 auto;
    box-shadow: 0 0 20px var(--accent);
}

/* Cards */
.card {
    background: #222;
    border: 4px solid #fff;
    border-radius: 10px;
    padding: 10px;
    width: 170px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 6px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
}

.card:hover {
    transform: scale(1.08);
    border-color: var(--red);
}

.card.beater {
    border-color: #00ff00 !important;
    box-shadow: 0 0 15px #00ff00;
}

.emoji {
    font-size: 2.6rem;
    margin-bottom: 6px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.card-header {
    font-size: 0.8rem;
    margin-bottom: 6px;
    text-align: center;
    word-break: break-word;     /* safety net */
    line-height: 1.2;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

td {
    padding: 3px 6px;
    border: 1px solid #444;
    text-align: center;
}

.region-header {
    background: #111;
    color: var(--accent);
}

/* Mobile: 2 cards per row + tighter text */
.hand {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .card {
        width: 48%;
        max-width: 165px;
        padding: 8px;
    }    
    .emoji {
        font-size: 2.4rem;
    }
}

/* Buttons & Modal */
.region-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.region-btn {
    background: #222;
    color: var(--accent);
    border: 3px solid var(--accent);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    min-width: 110px;
    white-space: nowrap;
}
.region-btn:hover {
    background: var(--accent);
    color: #000;
}
.region-btn span {
    margin-top: 3px;
}

.cancel-btn {
    background: #444;
    margin-top: 20px;
}

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1a1a1a;
    border: 6px solid var(--red);
    padding: 25px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    border-radius: 12px;
}

/* Log */
#message-log {
    background: #111;
    padding: 12px;
    height: 90px;
    overflow-y: auto;
    margin-bottom: 15px;
    font-size: 0.9rem;
    border: 2px solid #333;
    line-height: 1.5;
}

/* Buttons */
button {
    background: var(--red);
    color: #fff;
    border: none;
    padding: 14px 28px;
    font-family: 'Press Start 2P';
    font-size: 1rem;
    cursor: pointer;
    margin: 8px;
    border-radius: 6px;
}

button:hover {
    background: #ff3366;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 0;
    font-size: 0.75rem;
    color: #666;
    line-height: 1.6;
}
.footer a {
    color: #fff;
}
.footer a:hover {
    color: #ffcc00;
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    border: 8px solid var(--red);
    padding: 40px 30px;
    text-align: center;
    display: none;
    z-index: 2000;
    max-width: 90%;
}

.game-over h1 {
    font-size: 1.8rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* End-game modal glows */
.game-over h1.win {
    color: #00ffcc !important;
    text-shadow: 0 0 20px #00ffcc, 0 0 40px #00ffcc;
}
.game-over h1.lose {
    color: #ff0033 !important;
    text-shadow: 0 0 20px #ff0033, 0 0 40px #ff0033;
}

@media (max-width: 600px) {
    .game-over h1 {
        font-size: 1.5rem;
        white-space: normal;
        line-height: 1.3;
    }
}

/* Modal backdrop */
.modal {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* Highlight the chosen region row */
.card .highlight-row {
    background: #00ffcc !important;
    color: #000;
    font-weight: bold;
}

/* === ANIMATION IMPROVEMENTS === */

/* Button press effect */
button:active {
    transform: scale(0.92);
    filter: brightness(1.2);
}

/* Card hover & press */
.card {
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:active {
    transform: scale(0.92) translateY(4px);
}

/* Card played animation */
.card.played {
    animation: cardPlayedAnim 600ms forwards;
}
@keyframes cardPlayedAnim {
    0%   { transform: scale(1) rotate(0deg); opacity: 1; }
    100% { transform: scale(0.6) rotate(25deg) translateY(-120px); opacity: 0; }
}

/* Score flash on update */
.score-flash {
    animation: scoreFlash 600ms ease;
}
@keyframes scoreFlash {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); color: #00ffcc; text-shadow: 0 0 12px #00ffcc; }
    100% { transform: scale(1); }
}

/* Score glow for 1000+ */
.score-glow {
    animation: scoreGlow 2s infinite alternate ease-in-out;
}
@keyframes scoreGlow {
    from { text-shadow: 0 0 6px #ffcc00; }
    to   { text-shadow: 0 0 18px #ffcc00, 0 0 28px #ffcc00; }
}

/* Grey out low scores */
.score-grey {
    opacity: 0.8;
    filter: grayscale(30%);
}
.score-extra-grey {
    opacity: 0.5;
    filter: grayscale(50%);
}

.score-max {
    color: #ffff00 !important;
    text-shadow: 0 0 12px #ffff00, 0 0 20px #ffaa00;
    animation: max-pulse 1.2s infinite;
}
@keyframes max-pulse {
    50% { transform: scale(1.15); }
}
.game-over {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* Play prompt styling */
#play-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 204, 0, 0.15);
    border: 3px dashed #ffcc00;
    color: #ffcc00;
    padding: 20px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 0 30px #ffcc00;
    animation: promptPulse 2s infinite;
    z-index: 10;
}
@keyframes promptPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}