:root {
    --bg: #0d0d12;
    --card: #16161f;
    --accent: #b794f4;
    --accent-glow: rgba(183, 148, 244, 0.3);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.guestbook-app {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* --- HUGE HEADER --- */
.huge-header {
    text-align: center;
    padding: 5px 0; /* Reduced from 10px */
    position: relative;
}

.huge-header .logo {
    font-size: 3.5rem; /* Reduced from 4rem */
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -2px;
    background: linear-gradient(to bottom, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.huge-header .tagline {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 5px;
}

.lang-switch-absolute {
    position: absolute;
    top: 5px;
    right: 5px;
}

.lang-switch-absolute button {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* --- MAIN DRAWING AREA --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.drawing-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.canvas-wrapper {
    width: 100%;
    aspect-ratio: 2 / 1;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--accent);
}

#guestCanvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    touch-action: none;
}

/* --- COMPACT CONTROL GRID --- */
.control-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 12px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.tool-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mini-separator {
    border-left: 1px solid var(--border);
    padding-left: 6px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn.active {
    background: var(--accent);
    color: #000 !important; /* Ensure readability */
    box-shadow: 0 0 15px var(--accent-glow);
}

.tool-btn.secondary.active {
    background: var(--accent);
    color: #000 !important;
}

#opacitySlider {
    flex: 1;
    accent-color: var(--accent);
}

#colorPicker {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
}

/* --- TIMELINE --- */
.timeline-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.timeline {
    flex: 1;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 2px 0 25px 0; /* Space for timing labels */
}

.frame-thumb {
    min-width: 50px;
    height: 25px;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.frame-thumb.active {
    border-color: var(--accent);
}

.frame-thumb canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.frame-timing {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 2px;
    font-size: 0.65rem;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.timing-input-popup {
    width: 45px !important; /* Fix excessive width */
    background: #fff !important;
    color: #000 !important;
    border: none !important;
    font-size: 0.7rem !important;
    text-align: center;
    border-radius: 2px;
}

.add-frame-btn {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.submit-btn {
    flex: 1;
    height: 36px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 900;
    font-size: 0.8rem;
    cursor: pointer;
}

/* --- POPUP PREVIEW --- */
.preview-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 10px;
    z-index: 1000;
    box-shadow: 0 0 50px rgba(0,0,0,0.9);
}

.preview-header {
    font-size: 0.7rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.preview-box {
    width: 128px;
    height: 64px;
    background: #000;
    border: 1px solid var(--border);
}

#previewCanvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

/* --- MOBILE COMPACT --- */
@media (max-width: 480px) {
    .huge-header .logo { font-size: 3rem; }
    .huge-header .tagline { font-size: 1rem; }
    .drawing-container { padding: 8px; }
}

/* Modal Styling... */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 20px;
    width: 100%;
    max-width: 350px;
    text-align: center;
}

.modal-content h2 { font-size: 1.2rem; margin-bottom: 5px; }
.modal-content .subtext { font-size: 0.8rem; margin-bottom: 15px; }
.modal-content input, .modal-content textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: #fff;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; height: 40px; border-radius: 8px; cursor: pointer; border: none; font-weight: 700; }
.btn-cancel { background: #333; color: #fff; }
.btn-next, .btn-submit { background: var(--accent); color: #000; }

/* --- SCROLLING & OVERFLOW FIX --- */
body {
    overflow: auto !important; /* Allow scroll if content is long */
    height: auto !important;   /* Let body size to content */
    align-items: flex-start !important;
}

.guestbook-app {
    min-height: auto !important;
    height: auto !important;
}

/* --- BUTTON READABILITY FIX --- */
.tool-btn.secondary.active {
    background: var(--accent) !important;
    color: #000 !important;
    font-weight: 800;
}

/* --- TIMER INPUT WIDTH FIX --- */
.timing-input-popup {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    text-align: center;
}

/* --- HELP MODAL STYLING --- */
.help-content {
    max-width: 450px !important;
    text-align: left !important;
    padding: 25px !important;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 15px 0;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    line-height: 1.2;
}

.help-item span {
    font-size: 1.1rem;
    min-width: 35px; /* Fixed width for icon column */
    display: inline-block;
    text-align: center;
    flex-shrink: 0;
}

.help-step {
    margin-top: 15px;
}

.help-step strong {
    display: block;
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.help-step p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 15px 0;
}

#helpToggle {
    font-size: 0.7rem;
    padding: 4px 8px;
    font-weight: 900;
}

.canvas-hints {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 4px;
    padding: 0 5px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    pointer-events: none;
}

/* --- DISCLAIMER AREA --- */
#disclaimer-area.disclaimer-box {
    margin: 15px 0;
    padding: 12px;
    background: #1a1a24 !important; /* Solid dark grey/blue */
    border: 1px solid #334155 !important; /* Solid border */
    border-radius: 12px;
    font-size: 0.65rem;
    color: #94a3b8 !important; 
    text-align: center;
    line-height: 1.5;
    display: block !important;
    width: 100%;
}

#disclaimer-area.disclaimer-box p {
    margin-bottom: 6px;
    color: #94a3b8 !important;
    text-align: center;
}

.disclaimer-box p:last-child {
    margin-bottom: 0;
}

/* --- CANVAS EXAMPLE BACKGROUND --- */
.canvas-wrapper {
    position: relative;
    background: #000;
}

.canvas-bg-example {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.6; /* Increased visibility */
    pointer-events: none;
    z-index: 0;
    image-rendering: pixelated;
    transition: opacity 0.5s ease;
}

#guestCanvas {
    position: relative;
    z-index: 1;
    background: transparent !important; /* Allow background to show through */
}
