/* ============================================================
   THE FUN HOUSE — Sadistic Clown SQL Escape Room
   Kitschy Saw ripoff meets retro carnival aesthetic
   ============================================================ */

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

:root {
    --blood: #8b0000;
    --blood-glow: #ff0000;
    --clown-red: #cc0000;
    --clown-yellow: #ffd700;
    --clown-purple: #6b0080;
    --dark: #0a0a0a;
    --darker: #050505;
    --grime: #1a1a0e;
    --text: #d4cfc4;
    --text-dim: #8a856e;
    --accent: #ff4444;
    --success: #44ff44;
}

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

body {
    background: var(--darker);
    color: var(--text);
    font-family: 'Special Elite', 'Courier New', monospace;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.15) 2px,
        rgba(0,0,0,0.15) 4px
    );
    pointer-events: none;
    z-index: 1000;
}

/* Film grain */
body::after {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    z-index: 999;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(139,0,0,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(107,0,128,0.1) 0%, transparent 50%),
        var(--darker);
}

.clown-header {
    text-align: center;
    margin-bottom: 2rem;
}

.clown-face {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: bob 2s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.clown-face .eye { color: var(--clown-yellow); }
.clown-face .nose { margin: 0 0.3rem; }

.title {
    font-family: 'Creepster', cursive;
    font-size: 3.5rem;
    color: var(--clown-red);
    text-shadow:
        0 0 10px var(--blood-glow),
        0 0 40px rgba(255,0,0,0.3),
        3px 3px 0 var(--clown-purple);
    letter-spacing: 0.1em;
    line-height: 1.1;
}

.subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: var(--clown-yellow);
    letter-spacing: 0.3em;
    margin-top: 0.5rem;
}

/* Glitch effect */
.glitch {
    position: relative;
}
.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    overflow: hidden;
}
.glitch::before {
    color: #0ff;
    z-index: -1;
    animation: glitch-1 3s infinite linear alternate-reverse;
}
.glitch::after {
    color: #f0f;
    z-index: -2;
    animation: glitch-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0%, 90% { clip-path: inset(0 0 0 0); transform: translate(0); }
    92% { clip-path: inset(20% 0 40% 0); transform: translate(-3px, 1px); }
    94% { clip-path: inset(60% 0 10% 0); transform: translate(3px, -1px); }
    96% { clip-path: inset(30% 0 50% 0); transform: translate(-2px, 2px); }
    98% { clip-path: inset(70% 0 5% 0); transform: translate(2px, -2px); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}
@keyframes glitch-2 {
    0%, 88% { clip-path: inset(0 0 0 0); transform: translate(0); }
    90% { clip-path: inset(50% 0 20% 0); transform: translate(2px, -1px); }
    93% { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 1px); }
    96% { clip-path: inset(40% 0 30% 0); transform: translate(1px, 2px); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

.rules-box {
    background: linear-gradient(135deg, rgba(139,0,0,0.1), rgba(10,10,10,0.9));
    border: 1px solid var(--blood);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.rules-box h2 {
    font-family: 'Creepster', cursive;
    color: var(--clown-yellow);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    text-align: center;
}

.rules-box p {
    margin-bottom: 0.8rem;
    font-size: 1rem;
}

.rules-box ul {
    list-style: none;
    padding: 0;
}

.rules-box li {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(139,0,0,0.2);
    font-size: 0.95rem;
}

.rules-box li:last-child { border-bottom: none; }

.rules-box em {
    color: var(--accent);
    font-style: italic;
}

.rules-box strong {
    color: var(--clown-yellow);
}

/* Entry form */
.entry-form {
    text-align: center;
    margin-bottom: 2rem;
}

.entry-form label {
    display: block;
    font-family: 'Creepster', cursive;
    font-size: 1.3rem;
    color: var(--clown-yellow);
    margin-bottom: 0.8rem;
}

.entry-form input {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 1rem;
    padding: 0.8rem 1rem;
    background: rgba(26,26,14,0.8);
    border: 2px solid var(--blood);
    border-radius: 2px;
    color: var(--text);
    font-family: 'Special Elite', monospace;
    font-size: 1.1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.entry-form input:focus {
    border-color: var(--clown-yellow);
    box-shadow: 0 0 15px rgba(255,215,0,0.2);
}

.entry-form input::placeholder {
    color: var(--text-dim);
}

/* Continue box */
.continue-box {
    text-align: center;
    background: rgba(139,0,0,0.1);
    border: 1px solid var(--clown-red);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 4px;
}

.continue-box p { margin-bottom: 0.8rem; }

.tiny {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 1rem !important;
}

.tiny a { color: var(--text-dim); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    font-family: 'Creepster', cursive;
    font-size: 1.1rem;
    text-decoration: none;
    border: 2px solid;
    border-radius: 2px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-enter {
    background: var(--clown-red);
    border-color: var(--clown-yellow);
    color: var(--clown-yellow);
    width: 100%;
    max-width: 400px;
    font-size: 1.2rem;
}

.btn-enter:hover {
    background: var(--clown-yellow);
    color: var(--dark);
    box-shadow: 0 0 20px rgba(255,215,0,0.4);
}

.btn-go {
    background: transparent;
    border-color: var(--clown-yellow);
    color: var(--clown-yellow);
}

.btn-go:hover {
    background: var(--clown-yellow);
    color: var(--dark);
}

.btn-back {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.btn-back:hover {
    border-color: var(--text);
    color: var(--text);
}

.btn-submit {
    background: var(--clown-red);
    border-color: var(--clown-red);
    color: white;
    font-size: 1rem;
    width: 100%;
}

.btn-submit:hover {
    background: var(--blood-glow);
    border-color: var(--blood-glow);
    box-shadow: 0 0 15px rgba(255,0,0,0.3);
}

/* Footer links */
.footer-links {
    text-align: center;
    margin-top: 2rem;
}

.footer-links a {
    color: var(--text-dim);
    text-decoration: none;
    margin: 0 1rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover { color: var(--clown-yellow); }

/* Scrolling ticker */
.ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--blood);
    padding: 0.3rem 0;
    overflow: hidden;
    z-index: 100;
}

.ticker-inner {
    display: inline-block;
    white-space: nowrap;
    animation: scroll 20s linear infinite;
    color: var(--clown-yellow);
    font-family: 'Creepster', cursive;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

@keyframes scroll {
    from { transform: translateX(100vw); }
    to { transform: translateX(-100%); }
}

/* ============================================================
   ROOM PAGE
   ============================================================ */

.room-page {
    background:
        radial-gradient(ellipse at center, rgba(26,26,14,0.9) 0%, var(--darker) 100%);
}

.room-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
}

/* Progress bar */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.progress-bar {
    display: flex;
    gap: 0.3rem;
}

.progress-room {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    border: 2px solid;
}

.progress-room.done {
    background: var(--success);
    border-color: var(--success);
    color: var(--dark);
}

.progress-room.current {
    background: var(--clown-red);
    border-color: var(--clown-yellow);
    color: var(--clown-yellow);
    animation: pulse 1.5s ease-in-out infinite;
}

.progress-room.locked {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-dim);
    opacity: 0.4;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(204,0,0,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(204,0,0,0); }
}

.timer {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.2rem;
    color: var(--clown-red);
    text-shadow: 0 0 10px rgba(255,0,0,0.5);
    background: rgba(0,0,0,0.5);
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--blood);
    border-radius: 2px;
}

/* Room content */
.room-content {
    animation: fadeIn 0.5s ease-out;
}

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

.room-title {
    font-family: 'Creepster', cursive;
    font-size: 2rem;
    color: var(--clown-red);
    text-shadow: 0 0 15px rgba(255,0,0,0.3), 2px 2px 0 var(--clown-purple);
    margin-bottom: 1.5rem;
}

.room-description {
    background: rgba(26,26,14,0.6);
    border-left: 3px solid var(--blood);
    padding: 1.2rem;
    margin-bottom: 2rem;
    line-height: 1.7;
    font-size: 1rem;
}

.room-puzzle {
    background: linear-gradient(135deg, rgba(139,0,0,0.08), rgba(10,10,10,0.9));
    border: 1px solid var(--blood);
    border-radius: 4px;
    padding: 1.5rem;
}

.room-puzzle h2 {
    font-family: 'Creepster', cursive;
    color: var(--clown-yellow);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.question {
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.wrong-answer {
    background: rgba(255,0,0,0.1);
    border: 1px solid var(--clown-red);
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    border-radius: 2px;
    text-align: center;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

.clown-laugh {
    font-size: 1.2rem;
}

.wrong-answer {
    color: var(--accent);
}

/* Answer form */
.answer-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.answer-form input {
    flex: 1;
    padding: 0.8rem 1rem;
    background: rgba(10,10,10,0.8);
    border: 2px solid var(--blood);
    border-radius: 2px;
    color: var(--text);
    font-family: 'Special Elite', monospace;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.answer-form input:focus {
    border-color: var(--clown-yellow);
}

.answer-form button {
    white-space: nowrap;
}

/* Hint */
.hint-box {
    margin-top: 1rem;
    border-top: 1px dashed var(--text-dim);
    padding-top: 0.8rem;
}

.hint-box summary {
    cursor: pointer;
    color: var(--text-dim);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.hint-box summary:hover { color: var(--clown-yellow); }

.hint-sql {
    background: rgba(0,0,0,0.5);
    color: var(--success);
    padding: 1rem;
    margin-top: 0.5rem;
    border-radius: 2px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    border: 1px solid rgba(68,255,68,0.2);
}

/* ============================================================
   FINISH PAGE
   ============================================================ */

.finish-page {
    background:
        radial-gradient(ellipse at 50% 30%, rgba(255,215,0,0.05) 0%, transparent 50%),
        var(--darker);
    display: flex;
    align-items: center;
    justify-content: center;
}

.escape-banner {
    text-align: center;
    margin-bottom: 2rem;
}

.escape-banner .title {
    font-size: 3rem;
    color: var(--success);
    text-shadow: 0 0 20px rgba(68,255,68,0.3), 2px 2px 0 rgba(0,100,0,0.5);
}

.escape-banner .subtitle {
    color: var(--text-dim);
    font-family: 'Special Elite', monospace;
    font-size: 0.9rem;
    letter-spacing: 0;
    margin-top: 0.5rem;
}

.result-card {
    text-align: center;
    background: linear-gradient(135deg, rgba(139,0,0,0.15), rgba(10,10,10,0.9));
    border: 2px solid var(--clown-yellow);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 0 30px rgba(255,215,0,0.1);
}

.result-card .clown-face {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.result-card h2 {
    font-family: 'Creepster', cursive;
    font-size: 1.8rem;
    color: var(--clown-yellow);
    margin-bottom: 0.5rem;
}

.final-time {
    font-family: 'Press Start 2P', monospace;
    font-size: 2rem;
    color: var(--clown-red);
    text-shadow: 0 0 15px rgba(255,0,0,0.4);
    margin: 0.5rem 0;
}

.time-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.2em;
}

.result-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.post-escape-quote {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.95rem;
    border-top: 1px dashed var(--text-dim);
    padding-top: 1.5rem;
    margin-top: 1rem;
}

.attribution {
    font-family: 'Creepster', cursive;
    color: var(--clown-red);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

/* ============================================================
   LEADERBOARD & RESULTS
   ============================================================ */

.leaderboard-page,
.results-page {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(139,0,0,0.08) 0%, transparent 50%),
        var(--darker);
}

.page-title {
    font-family: 'Creepster', cursive;
    font-size: 2.2rem;
    color: var(--clown-yellow);
    text-shadow: 2px 2px 0 var(--clown-purple);
    text-align: center;
    margin-bottom: 0.3rem;
}

.page-subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.leaderboard-table th {
    font-family: 'Creepster', cursive;
    color: var(--clown-yellow);
    padding: 0.8rem;
    text-align: left;
    border-bottom: 2px solid var(--blood);
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.leaderboard-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid rgba(139,0,0,0.15);
    font-size: 0.95rem;
}

.leaderboard-table .rank {
    width: 3rem;
    text-align: center;
}

.leaderboard-table .time {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: var(--clown-red);
    text-align: right;
}

.leaderboard-table tr.gold {
    background: rgba(255,215,0,0.05);
}

.leaderboard-table tr.gold .name {
    color: var(--clown-yellow);
    font-size: 1.05rem;
}

.leaderboard-table tr.slowest {
    background: rgba(255,0,0,0.08);
}

.leaderboard-table tr.slowest .name {
    color: var(--accent);
    font-weight: bold;
}

.standup-callout {
    background: rgba(255,0,0,0.1);
    border: 2px solid var(--clown-red);
    padding: 1rem;
    text-align: center;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.standup-callout strong {
    color: var(--accent);
    font-size: 1.1rem;
}

.no-entries {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    font-size: 1.1rem;
}

/* Results grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .results-grid { grid-template-columns: 1fr; }
}

.result-section h2 {
    font-family: 'Creepster', cursive;
    font-size: 1.1rem;
    color: var(--clown-yellow);
    text-align: center;
    margin-bottom: 1rem;
}

.loser-card,
.winner-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: 4px;
}

.loser-card {
    background: rgba(255,0,0,0.08);
    border: 2px solid var(--clown-red);
}

.loser-card .clown-face {
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.loser-card h3 {
    font-family: 'Creepster', cursive;
    color: var(--accent);
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.loser-card .time {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: var(--clown-red);
}

.loser-card .shame {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
    font-style: italic;
}

.winner-card {
    background: rgba(68,255,68,0.05);
    border: 2px solid var(--success);
}

.winner-card h3 {
    font-family: 'Creepster', cursive;
    color: var(--success);
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.winner-card .time {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: var(--success);
}

.winner-card .glory {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Full ranking */
.full-ranking {
    background: rgba(26,26,14,0.6);
    border: 1px solid rgba(139,0,0,0.3);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.full-ranking h2 {
    font-family: 'Creepster', cursive;
    color: var(--clown-yellow);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.full-ranking ol {
    list-style: decimal;
    padding-left: 2rem;
}

.full-ranking li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(139,0,0,0.15);
}

.full-ranking li:last-child { border-bottom: none; }

.full-ranking .time {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: var(--clown-red);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .title { font-size: 2.2rem; }
    .subtitle { font-size: 0.6rem; }
    .room-title { font-size: 1.5rem; }
    .timer { font-size: 0.9rem; }
    .progress-room { width: 1.5rem; height: 1.5rem; font-size: 0.45rem; }
    .answer-form { flex-direction: column; }
    .btn-submit { width: 100%; }
}