:root {
    --primary: #6d28d9;
    --primary-dark: #5b21b6;
    --primary-light: #8b5cf6;
    --background: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --accent-red: #f43f5e;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --choice-left: #f1c2c7;
    --choice-middle: #c7e6d6;
    --choice-right: #c7dff7;
    --choice-height: 25vh;
    --transition-time: 0.5s;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Literata', serif;
    background-color: var(--background);
    color: var(--text);
    overflow: hidden;
    touch-action: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.title-bar {
    background-color: var(--surface);
    padding: 12px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.title-bar.visible {
    transform: translateY(0);
}

.app-container.show-menu .title-bar {
    transform: translateY(0);
}

.story-menu {
    position: relative;
    display: inline-block;
}

.story-title {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.3s;
    user-select: none;
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--accent-red), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.story-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--surface);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.story-menu:hover .story-dropdown,
.story-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section {
    padding: 10px 0;
    border-bottom: 1px solid rgba(52, 152, 219, 0.2);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-header {
    padding: 5px 15px;
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 15px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9em;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.title-bar h1 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--accent-red), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.url-form {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background-color: var(--surface);
    padding: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.url-form.active {
    transform: translateY(0);
}

#fink-url-input, #media-path-input {
    flex-grow: 1;
    padding: 10px 16px;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 0.9rem;
    margin-right: 2px;
}

#fink-url-input {
    border-radius: 8px 0 0 8px;
}

#media-path-input {
    border-radius: 0;
}

#fink-url-input:focus, #media-path-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
}

#load-fink-button {
    padding: 10px 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

#load-fink-button:hover {
    background-color: var(--primary-dark);
}

.story-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.image-container {
    position: relative;
    width: 100%;
    height: 78vh;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: height 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.1);
}

.image-container.fullscreen {
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
}

#story-image, #story-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 1s ease, transform 1.5s ease;
    transform-origin: center;
    max-height: 100%;
    max-width: 100%;
}

#story-video {
    display: none;
}

#story-image.hidden {
    opacity: 0;
}

.image-container.hidden {
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
}

#story-image.zoom-in {
    transform: scale(1.1);
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, var(--background), transparent);
    z-index: 1;
}

.choice-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.6);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    opacity: 0.6;
}

.choice-toggle:hover {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    opacity: 1;
    transform: scale(1.05);
}

.fullscreen-toggle {
    position: absolute;
    top: 57px;
    right: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.6);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    opacity: 0.6;
}

.fullscreen-toggle:hover {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    opacity: 1;
    transform: scale(1.05);
}

.story-content {
    position: absolute;
    bottom: 22vh;
    left: 0;
    right: 0;
    padding: 20px 24px;
    max-height: 40vh;
    overflow-y: auto;
    z-index: 3;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.85), transparent);
    transition: all 0.3s ease;
}

.story-content.choices-hidden {
    bottom: 0;
    max-height: 25vh;
}

#story {
    max-width: 900px;
    margin: 0 auto 1rem;
    font-size: 1.4rem;
    line-height: 1.8;
    transition: opacity 0.5s ease;
    padding-bottom: 5vh;
    font-weight: 400;
    color: var(--text);
    min-height: 200px;
}

#story p {
    margin-bottom: 1rem;
    animation: slide-up 0.5s ease forwards;
}

#story a {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

#story a:hover {
    color: #93c5fd;
    border-bottom-color: #60a5fa;
    text-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
}

#story a:visited {
    color: #a78bfa;
}

#story.fading {
    opacity: 0;
}

.status-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.status-overlay.active {
    opacity: 1;
    pointer-events: all;
}

#status {
    background-color: var(--surface);
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.2rem;
    text-align: center;
    max-width: 80%;
}

.status-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

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

.choices-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--choice-height);
    display: flex;
    z-index: 4;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 22vh;
}

.choices-container.hidden {
    transform: translateY(100%);
}

.choice {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    cursor: pointer;
    position: relative;
    overflow: visible;
    transition: all var(--transition-time) cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom center;
    min-height: 0;
}

.choice-1 { background-color: var(--choice-left); }
.choice-2 { background-color: var(--choice-middle); }
.choice-3 { background-color: var(--choice-right); }

.choice-emoji {
    font-size: 4rem;
    margin-bottom: 8px;
    transition: all var(--transition-time) cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: grayscale(30%) opacity(0.8);
    transform-origin: center;
}

.choice:hover .choice-emoji {
    filter: grayscale(0%) opacity(1);
    transform: scale(1.1);
}

.choice-label-svg {
    max-width: 100%;
    height: 40px;
    z-index: 5;
}

.choice-label-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-time) ease;
}

.choice-label-svg {
    max-width: 100%;
    height: 40px;
    z-index: 5;
}

.choice-label-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-time) ease;
}

.choice-text-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #000;
    text-align: center;
    margin-top: 8px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
    transition: all var(--transition-time) ease;
}

.choice:hover .choice-label {
    opacity: 1;
}

.menu-button, .fullscreen-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.menu-button:hover, .fullscreen-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.menu-trigger {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 15px;
    z-index: 5;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.fade-in {
    animation: fade-in 0.5s ease forwards;
}

.slide-up {
    animation: slide-up 0.5s ease forwards;
}

/* Sandbox iframe (hidden) */
#fink-sandbox {
    display: none;
}

/* Debug console */
#debug-console {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 200px;
    background: rgba(0, 0, 0, 0.9);
    color: #0f0;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid #333;
    display: none;
}

#debug-console.active {
    display: block;
}

#debug-toggle {
    position: fixed;
    top: 12px;
    right: 60px;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 6px;
    font-size: 10px;
    cursor: pointer;
    z-index: 1001;
    border-radius: 4px;
    font-family: monospace;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

#debug-toggle:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.8);
}