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

:root {
    --bg: #0a0a0a;
    --bg-elevated: #121212;
    --fg: #e8e8e8;
    --fg-muted: #888;
    --accent: #ff3333;
    --accent-dim: #cc2222;
    --card: #1a1a1a;
    --border: #2a2a2a;
    --success: #22cc22;
    --warning: #ffaa00;
}

@font-face {
    font-family: 'GameFont';
    src: local('system-ui'), local('-apple-system'), local('Segoe UI');
    font-display: swap;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'GameFont', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Landing Screen */
.landing-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.title {
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1.2;
    margin-bottom: 2.5rem;
    text-transform: uppercase;
    background: linear-gradient(180deg, var(--fg) 0%, #888 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(255, 51, 51, 0.3);
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 51, 51, 0.3); }
    50% { transform: scale(1.02); box-shadow: 0 0 40px rgba(255, 51, 51, 0.5); }
}

/* Buttons */
.btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.primary-btn {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px rgba(255, 51, 51, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

.primary-btn:hover {
    background: var(--accent-dim);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 51, 51, 0.5);
}

.primary-btn:active {
    transform: translateY(0);
}

.mute-btn {
    padding: 0.6rem 0.8rem;
    font-size: 1.2rem;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 8px;
}

.mute-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

/* Room Selection */
.room-selection-content {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.room-selection-content h2 {
    font-size: clamp(1.3rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--fg-muted);
    margin-bottom: 2rem;
    text-transform: uppercase;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    width: 100%;
}

.room-card {
    aspect-ratio: 4/3;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.room-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 50%, rgba(255,51,51,0.05) 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.room-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 30px rgba(255,51,51,0.15);
}

.room-card:hover::before {
    opacity: 1;
}

.room-card:active {
    transform: translateY(-2px) scale(0.98);
}

.room-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.room-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    padding: 1rem 1.5rem;
    position: relative;
    z-index: 5;
}

.stats {
    display: flex;
    gap: 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
}

.stats span:first-child { color: var(--warning); }
.stats span:nth-child(2) { color: var(--accent); }
.stats span:last-child { color: var(--success); }

.spot-btn:hover { border-color: var(--room-accent, var(--accent)); }
.spot-btn.selected { box-shadow: 0 0 20px var(--room-accent, var(--success)); }

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    width: 100%;
    max-width: 1000px;
}

.room-display {
    margin-bottom: 2rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.room-visual {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 16/9;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.room-visual::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(45deg, var(--accent), transparent, var(--accent));
    border-radius: 18px;
    opacity: 0;
    animation: borderPulse 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes borderPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

.room-label {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-muted);
    text-shadow: 0 0 30px rgba(255,51,51,0.2);
}

/* Retro canvas */
#game-canvas {
    width: min(92vw, 720px);
    height: auto;
    aspect-ratio: 3 / 2;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 3px solid var(--border);
    border-radius: 8px;
    background: #0a0a0a;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
    touch-action: none;
    cursor: pointer;
}

.message-log.highlight { color: var(--accent); font-weight: 700; }

/* Hiding Spots */
.hiding-spots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 400px;
    width: 100%;
}

.spot-btn {
    aspect-ratio: 1;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--fg);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.spot-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(255,51,51,0.2), transparent 70%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spot-btn:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: scale(1.05);
}

.spot-btn:hover::after {
    opacity: 1;
}

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

.spot-btn.selected {
    border-color: var(--success);
    background: rgba(34, 204, 34, 0.15);
    box-shadow: 0 0 20px rgba(34, 204, 34, 0.3);
}

.spot-btn.caught {
    border-color: var(--accent);
    background: rgba(255, 51, 51, 0.2);
    animation: shake 0.4s ease;
}

.spot-btn.safe {
    border-color: var(--success);
    background: rgba(34, 204, 34, 0.2);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* Message Log */
.message-log {
    margin-top: 2rem;
    min-height: 60px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.log-message {
    font-size: 0.95rem;
    color: var(--fg-muted);
    opacity: 0;
    transform: translateY(10px);
    animation: messageIn 0.4s ease forwards;
    line-height: 1.6;
}

.log-message.highlight {
    color: var(--accent);
    font-weight: 700;
}

@keyframes messageIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Chase Screen */
.chase-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.tetstack-chase {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--card);
    border: 4px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    animation: chaseFloat 2s ease-in-out infinite, chaseGlow 1s ease-in-out infinite alternate;
}

@keyframes chaseFloat {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-15px) rotate(1deg); }
}

@keyframes chaseGlow {
    0% { box-shadow: 0 0 20px rgba(255,51,51,0.2); }
    100% { box-shadow: 0 0 50px rgba(255,51,51,0.5), 0 0 100px rgba(255,51,51,0.2); }
}

.tetstack-chase img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chase-message {
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 600;
    color: var(--fg);
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chase-progress {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background: var(--card);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff6666);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

/* Result Screens */
.result-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: fadeInUp 0.6s ease-out;
}

.tetstack-result {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: var(--card);
    border: 4px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.tetstack-result img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tetstack-result.caught {
    border-color: var(--accent);
    animation: caughtPulse 0.8s ease-in-out infinite;
}

@keyframes caughtPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255,51,51,0.4); transform: scale(1); }
    50% { box-shadow: 0 0 50px rgba(255,51,51,0.7); transform: scale(1.02); }
}

.tetstack-result.missed {
    border-color: var(--success);
    animation: missedPulse 1.5s ease-in-out infinite;
}

@keyframes missedPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(34,204,34,0.3); }
    50% { box-shadow: 0 0 40px rgba(34,204,34,0.5); }
}

.tetstack-result.complaining {
    border-color: var(--warning);
    animation: complainShake 0.5s ease-in-out infinite;
}

@keyframes complainShake {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

.result-content h2 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.result-content h2.caught-title { color: var(--accent); }
.result-content h2.safe-title { color: var(--success); }
.result-content h2.complaining-title { color: var(--warning); }

.result-content p {
    font-size: 1.1rem;
    color: var(--fg-muted);
    max-width: 400px;
    line-height: 1.6;
}

.result-stats {
    display: flex;
    gap: 3rem;
    margin: 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fg-muted);
}

.result-stats span { color: var(--fg); }

.safe-note {
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--warning);
}

.spot-btn:disabled {
    cursor: default;
    opacity: 0.7;
}

.tetstack-chase.locked-on {
    border-color: var(--accent);
    animation: caughtPulse 0.4s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 480px) {
    .stats { gap: 1rem; font-size: 0.75rem; }
    .hiding-spots { gap: 0.75rem; max-width: 320px; }
    .room-grid { grid-template-columns: repeat(2, 1fr); }
    .result-stats { gap: 1.5rem; font-size: 1rem; }
}

@media (max-width: 360px) {
    .room-grid { grid-template-columns: 1fr; }
    .hiding-spots { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    .spot-btn { font-size: 1.2rem; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
.btn:focus-visible, .spot-btn:focus-visible, .room-card:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}