:root {
    /* Dark theme variables - now the default */
    --bg: #0e0e12;
    --panel: #121218;
    --text: #dcdce6;
    --muted: #a0a0aa;
    --accent: #800020;
    --accent-2: #a50a34;
    --border: #500a1e;
    --icon-gray: #8a8f98;
    --icon-on: #ffd54f;
    --slot-bg: #18191a;
    --slot-item: #f3f3f5;
    --slot-ink: #0e0e12;
    --highlight: #d14a5a;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: system-ui, Segoe UI, Roboto, Inter, -apple-system, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: calc(100vh - 60px);
    position: relative;
    overflow-x: hidden;
}

/* Interactive Grid Background */
.grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-background.active {
    opacity: 1;
}

.grid-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--accent) 1px, transparent 1px),
        linear-gradient(90deg, var(--accent) 1px, transparent 1px);
    background-size: 25px 25px;
    opacity: 0.6;
    mask: radial-gradient(circle 200px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 70%);
    -webkit-mask: radial-gradient(circle 200px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 70%);
}

/* Additional grid dots for better visibility */
.grid-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle 1px at center, var(--accent) 1px, transparent 1px);
    background-size: 25px 25px;
    opacity: 0.3;
    mask: radial-gradient(circle 200px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 70%);
    -webkit-mask: radial-gradient(circle 200px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 70%);
}

body {
    --mouse-x: 50%;
    --mouse-y: 50%;
}

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 10px 24px;
    background: rgba(18, 18, 24, 0.7);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid #2a2a32;
}

.icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: 1px solid var(--border);
    color: #fff;
    font-size: 16px;
    user-select: none;
    font-weight: 600;
    letter-spacing: 0.02em;
    overflow: hidden;
}

.icon-link {
    display: inline-grid;
    place-items: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    display: block;
    filter: invert(1);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-name {
    font-weight: 700;
    color: var(--text);
    font-size: 16px;
    white-space: nowrap;
}

.nav {
    justify-self: end;
    display: inline-flex;
    gap: 6px;
}

.nav-link {
    font-size: 14px;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: #101017;
    border-color: #2a2a32;
}

.tools-text {
    justify-self: end;
    font-size: 14px;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid transparent;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, font-weight 180ms ease;
}

.tools-text:hover {
    background: #101017;
    border-color: #2a2a32;
    font-weight: 700;
}

.tools-text:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.15);
}

/* Main centering helper */
.center {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    width: 100%;
}

/* Spinner Layout */
.wrap {
    display: grid;
    place-items: start center;
    padding: 18px;
}

.card {
    width: 100%;
    max-width: 1060px;
    display: grid;
    gap: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    align-items: start;
    z-index: 10;
}

@media (max-width: 900px) {
    .card {
        grid-template-columns: 1fr;
    }
    .brand-name {
        display: none;
    }
}

/* Controls */ 
.section-title {
    margin: 4px 0 8px;
    font-size: 18px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.input {
    background: #0f0f14;
    color: var(--text);
    border: 1px solid #777;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}

.btn {
    font-size: 14px;
    font-weight: 700;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    cursor: pointer;
}

.btn.secondary {
    background: #2a2a32;
    color: var(--text);
    border: 1px solid #3a3a44;
}

/* Spin button */
.btn.spin {
    --spin-red: #e53935;
    --spin-red-dark: #c62828;
    background: linear-gradient(180deg, var(--spin-red), var(--spin-red-dark));
    color: #fff;
    box-shadow: 0 6px 14px rgba(229, 57, 53, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.35) inset;
    transform: translateZ(0);
    transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn.spin:hover {
    filter: brightness(1.05);
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 10px 24px rgba(229, 57, 53, 0.35),
        0 0 0 1px rgba(0, 0, 0, 0.35) inset;
}

.btn.spin:active {
    transform: translateY(0);
    filter: brightness(0.98);
    box-shadow: 0 4px 10px rgba(229, 57, 53, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.5) inset;
}

/* Slot Spinner */
.slot-wrap {
    display: grid;
    place-items: center;
    gap: 10px;
}

.spin-game__slot-wrapper {
    position: relative;
    width: 320px;
    height: 260px;
    background: var(--slot-bg);
    border-radius: 12px;
    border: 2px solid #333;
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.27);
    outline: none;
    overflow: hidden;
}

.spin-game__pointer {
    position: absolute;
    left: 50%;
    top: -14px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-bottom: 32px solid var(--highlight);
    z-index: 2;
}

.spin-game__slot-list {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    will-change: transform;
}

.spin-game__slot-item {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--slot-item);
    color: var(--slot-ink);
    font-weight: 800;
    letter-spacing: 0.01em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    text-align: center;
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spin-game__slot-item--selected {
    outline: 2px solid rgba(255, 213, 79, 0.95);
    outline-offset: -2px;
}

.spin-game__slot-item--dimmed {
    filter: grayscale(0.25) opacity(0.95);
}

.spin-game__slot-item--far {
    filter: grayscale(0.55) opacity(0.8);
}

.spin-game__slot-item--near-miss {
    box-shadow: inset 0 0 0 2px rgba(209, 74, 90, 0.75);
}

.spin-game__highlight {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 48px;
    transform: translateY(-50%);
    border-top: 2px solid var(--highlight);
    border-bottom: 2px solid var(--highlight);
    pointer-events: none;
    z-index: 1;
}

.spin-controls {
    display: grid;
    place-items: center;
    gap: 8px;
    margin-top: 12px;
}

.result {
    min-height: 24px;
    font-weight: 800;
    text-align: center;
}

/* Manager */
.panel {
    background: #0f0f14;
    border: 1px solid #2a2a32;
    border-radius: 10px;
    padding: 10px;
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
    max-height: 560px;
    overflow: auto;
}

.row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    background: #12131a;
    border: 1px solid #292a33;
    border-radius: 8px;
    padding: 8px 10px;
    transition: opacity 0.2s, filter 0.2s;
}

.row .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row.excluded {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.actions {
    display: inline-flex;
    gap: 6px;
}

.iconbtn {
    background: #1a1b22;
    border: 1px solid #2b2c34;
    color: var(--icon-gray);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.iconbtn:hover {
    background: #101017;
}

.iconbtn.heart.on {
    color: var(--icon-on);
    background: rgba(128, 0, 32, 0.18);
    border-color: var(--border);
}

.iconbtn.cross.on {
    color: var(--icon-on);
    background: rgba(200, 200, 200, 0.12);
}

.iconbtn.trash {
    color: #e6a1ad;
    background: #2a1a1f;
    border-color: #4a2a33;
}

/* Dialog visibility via [hidden] */
#restaurant-list-dialog[hidden] {
    display: none;
}

#restaurant-list-dialog {
    position: fixed;
    inset: 0;
    background: rgba(14, 14, 18, 0.72);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Bottom clock */
.bottom-clock {
    position: fixed;
    inset: auto 0 10px 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 5;
    padding: 0 10px;
}

.bottom-clock span {
    pointer-events: auto;
    font-size: 13px;
    color: var(--text);
    opacity: 0.9;
    background: rgba(18, 18, 24, 0.9);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 8px;
    line-height: 1.2;
    user-select: text;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 520px) {
    .bottom-clock span { font-size: 12px; }
}

@media (max-width: 720px) {
    .brand-name { display: none; }
}

@media (max-width: 400px) {
    .topbar { padding: 0 8px; }
    .icon { width: 28px; height: 28px; font-size: 14px; }
}
