:root {
    --primary-color: #245d5a;
    --secondary-color: #d7ede8;
    --background-color: #f4efe6;
    --text-color: #24322d;
    --light-grey: #edf1ec;
    --medium-grey: #cfd8d0;
    --dark-grey: #52635a;
    --error-color: #b44335;
    --success-color: #3b7b59;
    --warning-color: #c28743;
    --border-radius: 18px;
    --box-shadow: 0 18px 40px rgba(25, 42, 34, 0.12);
}

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

body {
    font-family: Georgia, "Times New Roman", serif;
    margin: 0;
    padding: 15px;
    background: linear-gradient(180deg, #fbf8f1, var(--background-color));
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.container {
    background-color: rgba(255, 252, 246, 0.92);
    padding: 20px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(36, 93, 90, 0.12);
    width: 100%;
    max-width: 500px; /* Max width for mobile forms */
    margin-bottom: 20px;
}

h1, h2, h3, h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
}

p, label, input, textarea, select, button, li, span {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

h1 {
    font-size: 2em;
    margin-bottom: 25px;
}

h2 {
    font-size: 1.6em;
    border-bottom: 1px solid var(--light-grey);
    padding-bottom: 10px;
}

h4 {
    color: var(--dark-grey);
    font-size: 1.1em;
    margin-bottom: 10px;
}

p {
    margin-bottom: 10px;
}

/* --- Forms & Inputs --- */
input[type="text"],
input[type="color"],
textarea,
select {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 10px;
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--dark-grey);
}

/* --- Buttons --- */
button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.1s ease;
    display: inline-block;
    text-align: center;
    width: 100%; /* Make buttons full width by default */
    margin-top: 10px;
    box-shadow: 0 10px 18px rgba(36, 93, 90, 0.14);
}

button:hover:not(:disabled) {
    background-color: #1d4a47;
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(0px);
}

button:disabled {
    background-color: var(--medium-grey);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Specific button adjustments */
#home button {
    margin-bottom: 10px;
}

#home div {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}
#home div input[type="text"] {
    flex-grow: 1;
    margin-bottom: 0; /* Remove margin since flex handles spacing */
}
#home div button {
    width: auto; /* Allow join button to shrink */
    margin-top: 0;
}

/* --- Lobby --- */
#mobile-lobby ul,
#lobby ul /* Beamer list */ {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--light-grey);
    border-radius: var(--border-radius);
}

#mobile-lobby li,
#lobby li {
    padding: 10px 15px;
    border-bottom: 1px solid var(--light-grey);
}
#mobile-lobby li:last-child,
#lobby li:last-child {
    border-bottom: none;
}

.ready {
    color: var(--success-color);
    font-weight: bold;
}

.waiting {
    color: var(--warning-color);
    font-style: italic;
}

#host-controls {
    background-color: var(--light-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-top: 20px;
}

#host-controls div {
    margin-bottom: 10px;
}

#host-controls label {
    margin-bottom: 3px;
}

.lobby-status {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 12px 0 16px;
    padding: 10px 12px;
    border: 1px solid var(--light-grey);
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.62);
    color: var(--dark-grey);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.lobby-status strong {
    color: var(--primary-color);
}

/* --- Connection Bar --- */
.connection-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 8px 16px;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    color: white;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 0.9rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.3s ease;
}

.connection-bar.hidden {
    transform: translateY(-100%);
}

.connection-bar.connected {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: pulse-dot 1.2s ease-in-out infinite;
}

.connection-bar.connected .connection-dot {
    animation: none;
    opacity: 1;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* --- Chat --- */
#chat-area {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--light-grey);
    border-radius: var(--border-radius);
}

#chat-messages {
    height: 150px;
    overflow-y: scroll;
    background-color: white;
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius);
    padding: 10px;
    margin-bottom: 10px;
    font-size: 0.9em;
}

#chat-messages div {
    margin-bottom: 5px;
    word-wrap: break-word;
}

#chat-messages strong {
    color: var(--primary-color);
}

#chat-area div:has(> #chat-input) { /* Target the div containing input/button */
    display: flex;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    margin-bottom: 0;
}

#send-chat-button {
    width: auto; /* Allow send button to shrink */
    margin-top: 0;
    padding: 12px 15px;
}

/* --- Game Area (Mobile) --- */
#game-area {
    text-align: center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.game-header h2 {
    margin: 0;
    border: none;
    padding: 0;
    text-align: left;
}

.timer-badge {
    background: linear-gradient(180deg, #3d755e, #315f52);
    color: white;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(36, 93, 90, 0.2);
}

#prompt-area {
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--light-grey);
    border-radius: var(--border-radius);
    text-align: left;
}

#prompt-area h4 {
    text-align: left;
    margin-bottom: 8px;
}

#prompt-text {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0;
}

#prompt-image {
    max-width: 100%;
    max-height: 200px;
    border: 2px solid var(--medium-grey);
    border-radius: var(--border-radius);
    background-color: white;
    margin-top: 10px;
}

/* --- Drawing Interface --- */
.canvas-wrapper {
    background: #fff;
    border: 2px solid var(--medium-grey);
    border-radius: var(--border-radius);
    padding: 8px;
    margin: 10px auto 15px;
    max-width: 420px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

#drawing-canvas {
    border-radius: 10px;
    cursor: crosshair;
    touch-action: none;
    background-color: white;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    display: block;
}

.drawing-toolbar {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--light-grey);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 15px;
}

.tool-group {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tool-btn {
    width: 44px !important;
    height: 44px;
    border-radius: 12px;
    background: #fffaf0;
    border: 1px solid rgba(49, 95, 82, 0.2);
    cursor: pointer;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    margin: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.tool-btn.active {
    background: linear-gradient(180deg, #3d755e, #315f52);
    color: #fffaf0;
    border-color: #315f52;
}

.size-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--dark-grey);
}

.size-group label {
    display: inline;
    margin: 0;
    font-weight: normal;
}

.size-group input[type="range"] {
    width: 120px;
    margin: 0;
}

#brush-size-value {
    font-weight: bold;
    color: var(--primary-color);
    min-width: 20px;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    max-width: none;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: var(--primary-color);
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(36, 93, 90, 0.2);
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input-row #chat-input {
    flex-grow: 1;
    margin-bottom: 0;
}

.chat-input-row #send-chat-button {
    width: auto;
    margin-top: 0;
    padding: 10px 18px;
}

/* --- Beamer Page --- */
.beamer-body {
    background-color: #1a1a2e;
    color: white;
}

.beamer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.beamer-container h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-align: center;
    color: #4a89dc;
}

.beamer-container h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.beamer-container .container {
    background-color: #162447;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-width: 1200px;
    width: 100%;
}

.player-status-summary {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    font-size: 1.5rem;
}

.player-list-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

#player-list li {
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s;
}

#player-list li.ready {
    background-color: rgba(0, 255, 0, 0.2);
}

.qr-info {
    text-align: center;
    margin-top: 30px;
}

#qr-placeholder {
    max-width: 720px;
    margin: 0 auto;
}

/* Timer styles */
.timer-container {
    text-align: center;
    margin: 30px 0;
}

.countdown-timer {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto;
}

#timer-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
}

.timer-circle {
    width: 100px;
    height: 100px;
    transform: rotate(-90deg);
}

#timer-progress {
    fill: none;
    stroke: #4a89dc;
    stroke-width: 8;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.round-info {
    text-align: center;
    margin-bottom: 20px;
}

.submission-status {
    margin-top: 30px;
}

.progress-bar {
    height: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 15px 0;
    overflow: hidden;
}

#submission-progress {
    height: 100%;
    background-color: #4a89dc;
    transition: width 0.3s;
}

#submission-count {
    text-align: center;
    font-size: 1.2rem;
}

#submission-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    margin-bottom: 15px;
}

/* Results display */
#results-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.chain-card {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    width: calc(33.3% - 20px);
    min-width: 300px;
}

.chain-card h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #4a89dc;
}

.chain-step {
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.large-button {
    display: block;
    width: 250px;
    margin: 30px auto;
    padding: 15px 20px;
    font-size: 1.2rem;
    background-color: #4a89dc;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.large-button:hover {
    background-color: #3a79cc;
}

/* Drawing tools */
.drawing-tools {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
}

.drawing-tools button {
    width: 40px;
    height: 40px;
    margin: 0 5px;
    border-radius: 5px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: all 0.2s;
}

.drawing-tools button.active {
    background-color: #4a89dc;
    color: white;
    transform: scale(1.1);
}

#brush-size {
    width: 120px;
    margin: 0 10px;
}

#drawing-canvas {
    border: 2px solid #000;
    border-radius: 5px;
    background-color: white;
    cursor: crosshair;
    margin: 0 auto;
    display: block;
}

/* --- Utility & States --- */
.hidden {
    display: none;
}

.error-message {
    color: var(--error-color);
    font-weight: bold;
    margin-top: 10px;
}

.loading::after {
    content: '...';
    display: inline-block;
    animation: loading-dots 1s infinite steps(3, end);
    margin-left: 5px; /* Add space before dots */
    font-weight: bold;
}

@keyframes loading-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

#waiting-area h2 {
    font-style: normal;
    color: var(--dark-grey);
    font-weight: normal;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 15px 20px;
    }
    h1 { font-size: 1.8em; margin-bottom: 20px; }
    h2 { font-size: 1.4em; }
    button { padding: 10px 15px; }
    input[type="text"],
    textarea,
    select {
        padding: 10px 12px;
    }

    #drawing-canvas {
         max-width: 100%; /* Ensure canvas fits screen */
    }
}

/* Choice buttons on landing page */
.choice-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    width: 100%;
}

.choice-button {
    padding: 10px 20px;
    font-size: 16px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    max-width: 200px;
}

.choice-button:first-child {
    border-radius: 5px 0 0 5px;
}

.choice-button:last-child {
    border-radius: 0 5px 5px 0;
}

.choice-button.active {
    background-color: #4a89dc;
    color: white;
    border-color: #3a79cc;
}

/* Color palette for drawing */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 10px 0;
    max-width: 300px;
}

.color-option {
    width: 30px;
    height: 30px;
    margin: 3px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border: 2px solid #000;
    transform: scale(1.1);
} 

/* Cozy cabin pass */
body {
    background:
        linear-gradient(180deg, rgba(255, 248, 235, .82), rgba(231, 220, 196, .9)),
        url("/assets/cozy-camp.svg") center bottom / cover fixed;
}

.container {
    background-color: rgba(255, 252, 244, 0.9);
    border: 1px solid rgba(49, 95, 82, 0.16);
    border-radius: 22px;
    backdrop-filter: blur(12px);
}

button:not(.choice-button),
.large-button {
    background: linear-gradient(180deg, #3d755e, #315f52);
    border-radius: 14px;
}

button:not(.choice-button):hover:not(:disabled),
.large-button:hover {
    background: linear-gradient(180deg, #466f56, #264a40);
}

.choice-button {
    width: auto;
    margin-top: 0;
    background: rgba(255, 252, 244, 0.86);
    color: #315f52;
    border: 1px solid rgba(49, 95, 82, 0.24);
    box-shadow: none;
}

.choice-button:first-child {
    border-radius: 14px 0 0 14px;
}

.choice-button:last-child {
    border-radius: 0 14px 14px 0;
}

.choice-button.active {
    background: linear-gradient(180deg, #3d755e, #315f52);
    color: #fffaf0;
    border-color: #315f52;
}

.drawing-tools button {
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0 4px;
    border-radius: 12px;
    color: #20312a;
    background: #fffaf0;
    box-shadow: none;
}

.drawing-tools button.active {
    color: #fffaf0;
    background: #315f52;
}

.beamer-body {
    background:
        linear-gradient(180deg, rgba(22, 39, 39, .7), rgba(42, 55, 40, .82)),
        url("/assets/cozy-camp.svg") center bottom / cover fixed;
    color: #fff7df;
}

.beamer-container .container {
    background-color: rgba(24, 43, 40, 0.74);
    border: 1px solid rgba(255, 245, 220, 0.16);
    border-radius: 22px;
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.28);
}

.beamer-container h1,
.beamer-container h3,
.chain-card h3 {
    color: #ffd98a;
}

#timer-progress {
    stroke: #f0b55c;
}

#submission-progress {
    background: linear-gradient(90deg, #f0b55c, #7fb284);
}

.chain-card,
.chain-step,
.player-list-container,
.player-status-summary,
.beamer-controls-section {
    background-color: rgba(255, 248, 228, 0.1);
    border: 1px solid rgba(255, 245, 220, 0.14);
    border-radius: 18px;
}

.settings-item {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.settings-item select,
.settings-item input[type="number"] {
    border-radius: 12px;
    border: 1px solid rgba(255, 245, 220, 0.24);
    background: rgba(255, 252, 244, 0.92);
    color: #20312a;
}

.exquisite-mode #drawing-canvas {
    background:
        linear-gradient(180deg, transparent 32%, rgba(49, 95, 82, .12) 32%, rgba(49, 95, 82, .12) 34%, transparent 34%, transparent 66%, rgba(49, 95, 82, .12) 66%, rgba(49, 95, 82, .12) 68%, transparent 68%),
        #fffdf8;
}

.sentence {
    font-size: 1.1rem;
    line-height: 1.5;
    color: #fff7df;
}

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