/* =========================================
   PERILOUS PALACE :: STYLES
   Terminal / CRT aesthetic. Mobile-first.
   ========================================= */
 
:root {
    --bg:           #0b0c10;
    --bg-deep:      #050608;
    --green:        #33ff00;
    --green-dim:    #1a8800;
    --green-glow:   rgba(51, 255, 0, 0.7);
    --teal:         #45a29e;
    --red-warn:     #ff2a2a;
    --amber:        #ffb000;
 
    --font-mono:    'VT323', 'Courier New', monospace;
    --font-type:    'Creepster', 'Courier New', monospace;
}
 
* { box-sizing: border-box; }
 
html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--green);
    font-family: var(--font-mono);
    overflow: hidden;
    height: 100%;
    width: 100%;
    -webkit-font-smoothing: none;
    text-shadow: 0 0 5px var(--green-glow);
}
 
body {
    padding: 16px;
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
 
/* =====  CRT EFFECT (scanlines + faint flicker)  ===== */
 
.crt::before {
    content: " ";
    display: block;
    position: fixed;
    inset: 0;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%
    );
    z-index: 10;
    background-size: 100% 4px;
    pointer-events: none;
}
 
.crt::after {
    content: " ";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.5) 100%);
    z-index: 9;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}
 
@keyframes flicker {
    0%   { opacity: 0.95; }
    50%  { opacity: 1; }
    100% { opacity: 0.97; }
}
 
/* =====  SCENE SYSTEM  ===== */
 
#terminal {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    min-height: calc(100vh - 32px);
}
 
.scene { display: none; }
.scene.active { display: block; }
.hidden { display: none !important; }
 
/* =========================================
   SCENE: TERMINAL (boot + password + name)
   ========================================= */
 
#output p {
    margin: 0;
    line-height: 1;
    white-space: pre;
    font-size: 0.55rem; /* ASCII art default â€” tiny so 100 chars fit on mobile */
}
 
/* Standard sized text lines (mixed in with ASCII) */
#output p.text-line {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    line-height: 1.2;
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}
 
#output p.ascii-art {
    transform-origin: left center;
    line-height: 0.85;
}
 
/* On bigger screens the ASCII can breathe */
@media (min-width: 700px) {
    #output p { font-size: 0.9rem; }
    #output p.ascii-art {
        transform: scaleX(1.15);
        margin-left: 20px;
    }
}
 
#output p.warn { color: var(--red-warn); text-shadow: 0 0 5px var(--red-warn); }
#output p.ok   { color: var(--green); }
#output p.dim  { opacity: 0.55; }
 
#input-line {
    display: flex;
    align-items: center;
    margin-top: 15px;
    font-size: clamp(0.9rem, 3vw, 1.2rem);
}
 
.prompt { margin-right: 8px; color: var(--teal); flex-shrink: 0; }
 
#terminal-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: inherit;
    text-shadow: 0 0 5px var(--green-glow);
    flex: 1;
    min-width: 0;
    padding: 0;
    caret-color: transparent; /* hide native caret â€” we draw our own */
}
 
.cursor {
    display: inline-block;
    width: 0.6em;
    margin-left: -0.3em;
    animation: blink 1s step-end infinite;
}

/* ===== TERMINAL ENTER BUTTON ===== */
#enter-btn {
    background: transparent;
    color: var(--teal);
    border: 1px solid var(--teal);
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    margin-top: 20px;
    cursor: pointer;
    text-shadow: 0 0 5px var(--green-glow);
    box-shadow: inset 0 0 10px rgba(69, 162, 158, 0.1);
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    display: inline-block;
}

#enter-btn:hover, #enter-btn:active {
    background: rgba(69, 162, 158, 0.2);
    color: var(--green);
}

#enter-btn.hidden {
    display: none !important;
}
 
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
 
/* =========================================
   SCENE: ROOM (image + prompt + buttons)
   ========================================= */
 
.room-frame {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 12px;
    border: 2px solid var(--green-dim);
    box-shadow: 0 0 20px rgba(51, 255, 0, 0.15), inset 0 0 30px rgba(0,0,0,0.6);
    background: var(--bg-deep);
    min-height: calc(100vh - 64px);
    max-width: 600px;
    margin: 0 auto;
    animation: scene-fade-in 0.6s ease-out;
}
 
@keyframes scene-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
 
.room-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    border: 1px solid var(--green-dim);
    overflow: hidden;
}

/* Custom sizing for the map to stretch downwards */
.room-image-wrap.map-view {
    aspect-ratio: 3 / 4; /* A portrait aspect ratio to stretch the box vertically */
}

/* Ensure the full map is visible without cropping */
.room-image-wrap.map-view #room-image {
    object-fit: contain; 
}
 
#room-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(0.7) sepia(0.3) hue-rotate(60deg) brightness(0.85) contrast(1.1);
}
 
/* Faint green tint + scanline overlay on every image to keep terminal feel */
.image-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(51, 255, 0, 0.04), rgba(51, 255, 0, 0.04)),
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 2px,
            rgba(0,0,0,0.18) 2px,
            rgba(0,0,0,0.18) 3px
        );
    mix-blend-mode: screen;
    z-index: 3;
}
 
/* ===== PLACEHOLDER (shown when the image file is missing) ===== */
 
.image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px;
    gap: 16px;
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0,
            transparent 24px,
            rgba(51, 255, 0, 0.05) 24px,
            rgba(51, 255, 0, 0.05) 26px
        ),
        radial-gradient(ellipse at center, rgba(51, 255, 0, 0.10) 0%, transparent 70%);
    color: var(--green);
    font-family: var(--font-mono);
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
 
/* The placeholder is shown until an image successfully loads */
.room-image-wrap.image-missing .image-placeholder { opacity: 1; }
.room-image-wrap.image-missing #room-image { visibility: hidden; }
 
.placeholder-tag {
    color: var(--amber);
    text-shadow: 0 0 6px rgba(255, 176, 0, 0.5);
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    letter-spacing: 0.25em;
    opacity: 0.85;
    animation: tag-blink 2s ease-in-out infinite;
}
 
@keyframes tag-blink {
    0%, 70%, 100% { opacity: 0.85; }
    75%, 85%      { opacity: 0.35; }
}
 
.placeholder-label {
    font-size: clamp(1.1rem, 4.5vw, 1.6rem);
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px var(--green-glow);
    line-height: 1.3;
    word-break: break-word;
    max-width: 90%;
}
 
.placeholder-hint {
    font-size: clamp(0.7rem, 2.2vw, 0.85rem);
    opacity: 0.5;
    letter-spacing: 0.1em;
    margin-top: 4px;
    word-break: break-all;
    max-width: 90%;
}
 
.room-prompt {
    color: var(--red-warn);
    font-family: var(--font-type);
    font-size: clamp(1.1rem, 4.5vw, 1.6rem);
    text-shadow: 0 0 8px rgba(255, 42, 42, 0.6);
    line-height: 1.3;
    text-align: center;
    min-height: 2.5em;
    padding: 0 8px;
    letter-spacing: 0.02em;
}
 
.room-prompt.pick-prompt {
    color: var(--red-warn);
    font-size: clamp(1.4rem, 5vw, 1.9rem);
    animation: pick-pulse 1.2s ease-in-out infinite;
}
 
@keyframes pick-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}
 
/* The buttons */
.room-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}
 
.choice-btn {
    background: transparent;
    color: #d678ff;
    border: 1px solid var(--green-dim);
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: clamp(1rem, 4vw, 1.25rem);
    text-align: left;
    cursor: pointer;
    text-shadow: 0 0 6px rgba(214, 120, 255, 0.5);
    transition: background 0.15s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
 
.choice-btn::before {
    content: '> ';
    color: var(--green);
    text-shadow: 0 0 5px var(--green-glow);
}
 
.choice-btn:hover,
.choice-btn:focus-visible {
    background: rgba(51, 255, 0, 0.08);
    outline: none;
}
 
.choice-btn:active { transform: translateY(1px); }
 
.choice-btn[disabled] {
    opacity: 0.35;
    pointer-events: none;
}
 
/* Fade in choices after the 7-second hold */
.room-choices.revealing .choice-btn {
    opacity: 0;
    animation: choice-fade 0.4s ease-out forwards;
}
.room-choices.revealing .choice-btn:nth-child(1) { animation-delay: 0.0s; }
.room-choices.revealing .choice-btn:nth-child(2) { animation-delay: 0.15s; }
.room-choices.revealing .choice-btn:nth-child(3) { animation-delay: 0.30s; }
 
@keyframes choice-fade {
    to { opacity: 1; }
}
 
/* =========================================
   SCENE: FAIL ENDING
   ========================================= */
 
#scene-fail .fail-message {
    max-width: 600px;
    margin: 15vh auto 0;
    padding: 24px;
    text-align: center;
    font-family: var(--font-type);
    animation: scene-fade-in 0.8s ease-out;
}
 
.fail-line-1, .fail-line-2 {
    color: var(--red-warn);
    text-shadow: 0 0 8px rgba(255, 42, 42, 0.7);
    font-size: clamp(1.2rem, 5vw, 1.7rem);
    margin: 0.3em 0;
    line-height: 1.4;
}
 
.fail-follow {
    margin-top: 3em;
    color: var(--green);
    font-size: clamp(1rem, 4vw, 1.3rem);
}
 
.fail-follow a {
    color: #d678ff;
    text-decoration: none;
    text-shadow: 0 0 6px rgba(214, 120, 255, 0.5);
}
 
.fail-follow a:hover { text-decoration: underline; }
 
/* =========================================
   SCENE: POWER OFF
   ========================================= */
 
#scene-off {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 20;
}
 
.power-off-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--green);
    animation: power-down 1.2s ease-out forwards;
}
 
@keyframes power-down {
    0%   { width: 100vw; height: 8px;  opacity: 1; }
    40%  { width: 4px;   height: 8px;  opacity: 1; }
    80%  { width: 4px;   height: 4px;  opacity: 1; }
    100% { width: 0;     height: 0;    opacity: 0; }
}
 
/* When power-off scene is shown, kill the CRT overlays so the screen really goes dark */
body.powered-off::before,
body.powered-off::after { display: none; }
 
/* =========================================
   SCENE: INVITE (final reveal after RSVP)
   ========================================= */
 
#scene-invite {
    min-height: calc(100vh - 32px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8px 0 32px;
}
 
.invite-frame {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: scene-fade-in 0.8s ease-out;
}
 
.invite-poster {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--green-dim);
    box-shadow: 0 0 20px rgba(51, 255, 0, 0.15);
}
 
.invite-details {
    width: 100%;
    text-align: center;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
 
.invite-label {
    margin: 0;
    color: var(--teal);
    font-family: var(--font-mono);
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    letter-spacing: 0.25em;
    opacity: 0.85;
}
 
.invite-address {
    margin: 0;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 5.5vw, 1.9rem);
    letter-spacing: 0.12em;
    line-height: 1.25;
    text-shadow: 0 0 8px var(--green-glow);
}
 
.invite-time {
    margin: 0;
    color: var(--red-warn);
    font-family: var(--font-type);
    font-size: clamp(1.2rem, 4.8vw, 1.6rem);
    text-shadow: 0 0 8px rgba(255, 42, 42, 0.6);
    letter-spacing: 0.04em;
    line-height: 1.3;
}
 
/* On taller screens, give a touch more breathing room above */
@media (min-height: 800px) {
    #scene-invite { align-items: center; padding: 32px 0; }
}
 
/* =========================================
   UTILS
   ========================================= */
 
.shake { animation: shake 0.35s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}