:root {
    --card: rgba(17, 17, 17, 0.74);
    --line: rgba(255, 255, 255, 0.12);
    --text: #f6f6f6;
    --muted: rgba(255, 255, 255, 0.78);
    --accent: #ffd166;
    --success: #97f0a8;
    --shadow: rgba(0, 0, 0, 0.35);
    --radius: 16px;
    --radius-sm: 12px;
    --maxw: 860px;
    --tap: 44px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: var(--text);
    font-family: "Rubik", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    overflow-x: hidden;
    overflow-y: auto;
}

.app {
    min-height: 100dvh;
    position: relative;
    isolation: isolate;
    background: #000;
}

/* Background layers */
.bg-fill {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: blur(18px) saturate(1.05) brightness(0.72);
    transform: scale(1.08);
    opacity: 0;
    transition: opacity 900ms ease;
    z-index: -3;
    pointer-events: none;
}

.photo {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    opacity: 0;
    transition: opacity 1200ms ease;
    z-index: -2;
    pointer-events: none;
}

.scrim {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 20%, rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.38)), linear-gradient(to bottom, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.54));
    z-index: -1;
    pointer-events: none;
}

.app.loaded .bg-fill,
.app.loaded .photo {
    opacity: 1;
}

.shell {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 12px 12px 18px;
    display: grid;
    gap: 12px;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 10px 24px var(--shadow);
    padding: 10px;
}

.brand {
    min-width: 0;
}

.brand .title {
    font-weight: 800;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    line-height: 1.15;
    white-space: normal;
    word-break: break-word;
}


.top-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.top-actions::-webkit-scrollbar {
    display: none;
}

.top-select,
.top-btn {
    padding: 8px 10px;
    touch-action: manipulation;
}

.top-select {
    width: auto;
    flex-grow: 1;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 32px;
    cursor: pointer;
}

.spill-card-main {
    grid-column: 1 / -1;
}

.top-select,
.top-btn {
    min-height: 38px;
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}


.top-select option {
    color: #111;
    background: #fff;
}

.top-btn {
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
}

.top-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 10px 24px var(--shadow);
    padding: 12px;
}

.card h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.small {
    font-size: 0.84rem;
    color: var(--muted);
}

.banner {
    display: none;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    line-height: 1.25;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(17, 17, 17, 0.84);
}

.banner.show {
    display: block;
}

.banner.error {
    border-color: rgba(255, 139, 139, 0.35);
    background: rgba(59, 14, 14, 0.78);
    color: #ffd9d9;
}

.banner.info {
    border-color: rgba(124, 198, 254, 0.35);
    background: rgba(12, 30, 43, 0.78);
    color: #d9f0ff;
}

.declaration-box {
    border: 1px dashed rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.24);
    border-radius: 14px;
    padding: 12px;
    margin: 6px 0 12px;
}

.declaration-editor {
    margin: 0;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 700;
    font-size: 1.18rem;
    line-height: 1.16;
    color: #fff9ec;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.35rem;
}

.declaration-editor .txt {
    white-space: pre-wrap;
}

.inline-field {
    font: inherit;
    color: #fff;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 4px 8px;
    min-height: 1.9em;
    line-height: 1.1;
    outline: none;
    box-shadow: none;
}

.inline-field:focus {
    border-color: rgba(124, 198, 254, 0.9);
    box-shadow: 0 0 0 3px rgba(124, 198, 254, 0.16);
}

.inline-name {
    min-width: 9.2ch;
    width: min(32ch, 52vw);
    max-width: 100%;
    font-family: "Rubik", system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.15;
    padding: 7px 9px;
    vertical-align: middle;
}

.inline-name::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.inline-room {
    font-family: "Rubik", system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.15;
    padding: 7px 9px;
    min-width: 10ch;
    max-width: 100%;
    cursor: pointer;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 10px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 30px;
}

.inline-room option {
    color: #111;
    background: #fff;
}

.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.btn {
    min-height: var(--tap);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.9);
    color: #191919;
    font: inherit;
    font-weight: 800;
    padding: 10px 14px;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease, background 120ms ease;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
    touch-action: manipulation;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(180deg, #fff5d6, #ffd166);
    color: #2c2100;
    border-color: rgba(255, 209, 102, 0.55);
}

.status-line {
    margin: 8px 0 0;
    font-size: 0.83rem;
    color: var(--muted);
    min-height: 1.1em;
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.queue-count {
    font-size: 0.84rem;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.queue-list {
    display: grid;
    gap: 8px;
    max-height: min(48dvh, 520px);
    overflow: auto;
    padding-right: 2px;
}

.queue-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: start;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.20);
    padding: 10px;
}

.queue-line {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.26;
    color: #fff;
    word-break: break-word;
}

.queue-meta {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.queue-meta .pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
}

.remove-btn {
    align-self: center;
    min-height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(151, 240, 168, 0.35);
    background: rgba(151, 240, 168, 0.12);
    color: #d6ffe0;
    font: inherit;
    font-weight: 700;
    padding: 8px 10px;
    cursor: pointer;
    white-space: nowrap;
}

.remove-btn:hover {
    background: rgba(151, 240, 168, 0.18);
}

.empty {
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.16);
    padding: 14px;
    color: var(--muted);
    font-size: 0.92rem;
    text-align: center;
}

.footer-note {
    text-align: center;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.78rem;
    padding: 2px 6px 10px;
}

@media (min-width: 600px) {
    .topbar {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .top-actions {
        width: auto;
        min-width: 280px;
    }

    .brand .title {
        font-size: 1.03rem;
        white-space: nowrap;
    }
}

@media (min-width: 760px) {
    .shell {
        padding: 16px 16px 22px;
        gap: 14px;
    }

    .grid {
        grid-template-columns: 1fr 1.1fr;
        align-items: start;
    }

    .card {
        padding: 14px;
    }

    .declaration-editor {
        font-size: 1.38rem;
    }

    .inline-name,
    .inline-room {
        font-size: 0.95rem;
    }

    .queue-list {
        max-height: min(62dvh, 680px);
    }
}

@media (prefers-reduced-motion: reduce) {

    .bg-fill,
    .photo,
    .btn {
        transition: none !important;
    }
}

/* About modal */
.modal-backdrop[hidden] {
    display: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-card {
    width: min(640px, 100%);
    background: rgba(17, 17, 17, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
    padding: 16px 16px 14px;
    position: relative;
}

.modal-card h2 {
    margin: 0 34px 10px 0;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.15;
}

.modal-body {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1.35;
}

.modal-body p {
    margin: 0 0 10px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body a {
    color: #ffd166;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.14);
}
/* Spill The Beans Modal & Comments */
.spill-card {
    display: flex;
    flex-direction: column;
    max-height: 90dvh;
    padding: 16px 16px 0;
    /* Removing bottom padding to flush the keypad */
}

.spill-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
}

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

.comment-author {
    font-weight: 800;
    color: var(--accent);
    font-size: 0.9rem;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--muted);
}

.comment-text {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 8px;
    word-break: break-word;
}

.comment-actions .reply-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
}

.comment-actions .reply-btn:hover {
    color: #fff;
}

.comment-replies {
    margin-left: 20px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* T9 Compose Area */
.t9-compose-area {
    flex-shrink: 0;
}

.t9-replying-to {
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.t9-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--line);
    color: #fff;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 1rem;
    outline: none;
    resize: none;
    caret-color: transparent;
    /* Deny visual native cursor */
}

.t9-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.t9-input.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.2);
    background: rgba(0, 0, 0, 0.8);
}

/* The Keypad */
.t9-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-bottom: 16px;
    flex-shrink: 0;
}

.t9-key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #fff;
    padding: 12px 0;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    text-align: center;
    transition: background 100ms;
    touch-action: manipulation;
}

.t9-key:active {
    background: rgba(255, 255, 255, 0.25);
}

.t9-key span {
    display: block;
    font-size: 0.7rem;
    font-weight: normal;
    color: var(--muted);
    min-height: 12px;
    margin-top: 2px;
    touch-action: manipulation;
}

.t9-key.func {
    background: rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
}
/* Comment Meta & Delete Button */
.comment-meta-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.delete-bean-btn {
    background: rgba(255, 139, 139, 0.15);
    border: 1px solid rgba(255, 139, 139, 0.3);
    color: #ff9999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 6px;
    transition: background 150ms ease, color 150ms ease;
}

.delete-bean-btn:hover {
    background: rgba(255, 139, 139, 0.3);
    color: #fff;
}

.delete-bean-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Podium & Leaderboard */
.podium-card-main {
    grid-column: 1 / -1;
}

.top-btn.active-tab {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 20px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30%;
    max-width: 100px;
    text-align: center;
}

.podium-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.podium-bar {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 8px;
    font-weight: 800;
    color: #111;
    border-radius: 8px 8px 0 0;
    transition: height 0.4s ease;
}

.podium-bar.gold {
    background: linear-gradient(180deg, #ffe066, #ffcc00);
    height: 120px;
}

.podium-bar.silver {
    background: linear-gradient(180deg, #e0e0e0, #b3b3b3);
    height: 90px;
}

.podium-bar.bronze {
    background: linear-gradient(180deg, #e6a87c, #cd7f32);
    height: 60px;
}

/* Stars */
.star-rating {
    font-size: 3rem;
    display: flex;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.star {
    color: rgba(255, 255, 255, 0.2);
    transition: color 0.2s ease, transform 0.1s ease;
}

.star.active {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(255, 209, 102, 0.4);
}

.star:active {
    transform: scale(0.9);
}