body {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 10px;
    transition: background-color 1s ease;
    min-height: 100vh;
}

#game-container {
    width: 1200px;
    max-width: 100%;
    padding: 10px;
    background-color: rgba(1,1,1,0.1);
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    transition: opacity 1s ease;
    box-sizing: border-box;
}

#game-container.dimmed {
    opacity: 0.5;
}

#stats-bar {
    margin-bottom: 10px;
    padding: 10px;
    background-color: var(--space7);
    border: 4px solid var(--space4);
    border-radius: 5px;
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 8px;
}

#stats-bar p {
    margin: 5px 0;
}

#main-layout {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

.screen {
    padding: 10px;
    border: 4px solid var(--space4);
    border-radius: 5px;
    background-color: var(--space7);
    box-sizing: border-box;
}

#left-column {
    width: 25%;
    display: flex;
    flex-direction: column;
    gap: 0px;
    overflow-y: auto;
    max-height: 82vh;
}

#pond {
    width: 100%;
}

/* #farms removed -- each farm is now its own .screen section like seaweed/soybean */

#restaurant {
    width: 50%;
    position: relative;
}

#store {
    width: 25%;
    overflow-y: auto;
    max-height: 82vh;
}

h2 {
    color: var(--space1);
    text-align: center;
    margin-top: 0;
    font-size: 18px;
}

button {
    padding: 8px 16px;
    margin: 5px 0;
    background-color: var(--space3);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s, transform 0.2s;
    display: block;
    width: 100%;
    touch-action: manipulation;
}

.table, .cockroach, .equip-slot, .rest-tab-btn, .tab-btn {
    touch-action: manipulation;
}

button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
}

#btn-reset {
    background-color: #8b0000;
    margin-top: 12px;
}

#btn-reset:hover {
    background-color: #b00000;
}

#time-display {
    font-size: 16px;
    margin-bottom: 10px;
    text-align: center;
}

#restaurant-area {
    position: relative;
    background-color: var(--space0);
    border: 4px solid var(--space4);
    border-radius: 5px;
    padding: 6px;
}

/* Staff strip: chef + waiter icons above the table grid */
#staff-strip {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 4px 2px 6px;
}

.staff-sprite {
    width: 40px;
    height: 40px;
}

#tables {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}


.table {
    min-height: 100px;
    background-color: #8d5524;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 6px 4px 4px;
    cursor: pointer;
    transition: background-color 0.15s;
    touch-action: manipulation;
}

.table:hover {
    background-color: #a5642c;
}

/* Static glow when a customer is ready to be served */
.table.table-ready {
    box-shadow: 0 0 10px 4px rgba(76, 175, 80, 0.75);
}

/* Transient walk-in / walk-out sprite overlaid on #restaurant-area */
.anim-customer {
    position: absolute;
    width: 40px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
    z-index: 10;
}

/* Customer image embedded in table card */
.table-customer {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Order emoji inside card */
.order-display {
    font-size: 16px;
    min-height: 20px;
    text-align: center;
    line-height: 1.2;
}

#pond-visual {
    font-size: 50px;
    text-align: center;
    margin: 20px 0;
    animation: wave 2s infinite;
}

@keyframes wave {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

/* Decor / Ambience (C6) */
#restaurant-area {
    transition: background-color 3s ease;
}

#decor-strip {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 18px;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    letter-spacing: 2px;
}

#decor-section {
    padding: 6px 0 6px;
    border-bottom: 2px solid var(--space4);
    margin-bottom: 6px;
}

#decor-header {
    font-size: 12px;
    margin-bottom: 4px;
}

#btn-buy-decor {
    font-size: 12px;
    padding: 5px 8px;
}

/* Contract panel (C5) */
#contract-panel:not(:empty) {
    margin-bottom: 8px;
}

.contract-offer {
    background: rgba(180, 140, 0, 0.15);
    border: 2px solid #b8960a;
    border-radius: 5px;
    padding: 8px;
    margin-bottom: 6px;
    animation: pulse 2s infinite;
}

.contract-offer strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
}

.contract-offer p {
    font-size: 11px;
    margin: 2px 0 4px;
}

.contract-offer small {
    font-size: 10px;
    opacity: 0.8;
}

.btn-contract-accept {
    background-color: #2e7d32 !important;
    font-size: 11px !important;
    padding: 3px 8px !important;
    width: auto !important;
    display: inline-block !important;
    margin-right: 4px;
}

.btn-contract-decline {
    background-color: #8b0000 !important;
    font-size: 11px !important;
    padding: 3px 8px !important;
    width: auto !important;
    display: inline-block !important;
}

.contracts-active {
    margin-bottom: 6px;
}

.contract-active-row {
    font-size: 11px;
    padding: 2px 4px;
    background: rgba(21, 101, 192, 0.2);
    border-left: 3px solid #1565c0;
    margin-bottom: 2px;
    border-radius: 2px;
}

/* Equipment bar (C3) */
#equipment-bar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    padding: 6px;
    background: var(--space6);
    border-radius: 4px;
}

.equip-slot {
    flex: 1;
    min-width: 54px;
    font-size: 11px;
    padding: 5px 2px;
    text-align: center;
    line-height: 1.3;
}

.equip-owned {
    background-color: #2e7d32 !important;
    cursor: default;
}

.equip-available {
    background-color: var(--space3);
}

.equip-locked {
    background-color: var(--space5) !important;
    opacity: 0.65;
    cursor: not-allowed;
}

/* Staff section + XP bars (C4) */
.staff-section-wrapper {
    margin-top: 10px;
    border-top: 2px solid var(--space4);
    padding-top: 8px;
}

.staff-section-wrapper h3 {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: var(--space1);
    text-align: center;
}

.staff-entry {
    margin-bottom: 8px;
    font-size: 12px;
}

.xp-bar {
    height: 6px;
    background: var(--space5);
    border-radius: 3px;
    overflow: hidden;
    margin: 3px 0;
}

.xp-fill {
    height: 100%;
    background: #1565c0;
    border-radius: 3px;
    transition: width 1s linear;
}

/* Research section (C1) */
.research-section {
    margin-top: 10px;
    border-top: 2px solid var(--space4);
    padding-top: 8px;
}

.research-section h3 {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: var(--space1);
    text-align: center;
}

.btn-research {
    font-size: 12px;
    padding: 5px 8px;
    margin: 3px 0;
    text-align: left;
}

.btn-research-done {
    background-color: var(--space5) !important;
    opacity: 0.6;
}

.btn-research-active {
    background-color: #1565c0 !important;
    animation: pulse 1.5s infinite;
}

.btn-research-locked {
    background-color: var(--space6) !important;
    opacity: 0.7;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* Patience bar -- embedded in table card, not absolutely positioned */
.patience-bar {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    margin-top: auto;
}

.patience-fill {
    height: 100%;
    width: 100%;
    transition: width 1s linear;
}

.patience-fill.green  { background: #4caf50; }
.patience-fill.yellow { background: #ff9800; }
.patience-fill.red    { background: #f44336; }

/* ---- Menu display (restaurant panel) ---- */
#menu-display {
    margin: 4px 0 8px;
    padding: 6px 8px;
    background: var(--space6);
    border: 2px solid var(--space4);
    border-radius: 4px;
    font-size: 12px;
}

.menu-header {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    text-align: center;
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--space5);
}

.menu-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: baseline;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.menu-row:last-child {
    border-bottom: none;
}

.menu-ident {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-price {
    color: #4caf50;
    white-space: nowrap;
}

.menu-cost {
    font-size: 10px;
    opacity: 0.55;
    white-space: nowrap;
}

#store-visual {
    text-align: center;
}

#console {
    margin-top: 10px;
    padding: 10px;
    background-color: var(--space7);
    border: 4px solid var(--space4);
    border-radius: 5px;
    height: 150px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#console h3 {
    margin: 0 0 5px 0;
    font-size: 14px;
}

#console-messages {
    font-size: 12px;
    line-height: 1.4;
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* ---- E6: Accessibility ---- */

/* Keyboard focus ring (visible only for keyboard nav, not mouse) */
button:focus-visible {
    outline: 2px solid var(--space3);
    outline-offset: 2px;
}

/* Reduced motion: disable all decorative animations */
@media (prefers-reduced-motion: reduce) {
    #pond-visual {
        animation: none;
    }
    .contract-offer,
    .btn-research-active,
    #btn-prestige,
    #event-banner {
        animation: none;
        opacity: 1;
    }
    .money-float {
        animation: none !important;
        display: none;
    }
    .game-toast {
        transition: opacity 0.05s;
        transform: none !important;
    }
    .sprite {
        transition: none;
    }
    .patience-fill {
        transition: none;
    }
    .xp-fill {
        transition: none;
    }
}

/* ---- E7: Visuals ---- */

/* 3s day/night sunset gradient transition (overrides 1s from global style.css) */
body {
    transition: background-color 3s ease;
}

/* Kitchen status bar */
#kitchen-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: var(--space6);
    border: 2px solid var(--space4);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
    min-height: 28px;
}

#kitchen-status {
    flex: 1;
    opacity: 0.9;
}

/* Floating +$X money bubble on serve */
.money-float {
    position: absolute;
    font-weight: bold;
    font-size: 13px;
    color: #4caf50;
    pointer-events: none;
    animation: money-rise 1s ease-out forwards;
    z-index: 15;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

@keyframes money-rise {
    0%   { opacity: 1;   transform: translateY(0)    scale(1);   }
    20%  { opacity: 1;   transform: translateY(-8px) scale(1.1); }
    100% { opacity: 0;   transform: translateY(-44px) scale(0.9); }
}

@media (max-width: 768px) {
    #game-container {
        padding: 5px;
    }

    #stats-bar {
        font-size: 12px;
        gap: 5px;
        padding: 5px;
    }

    #stats-bar p {
        margin: 3px 0;
    }

    .stat-label {
        display: none;
    }

    #main-layout {
        flex-direction: column;
    }

    #left-column {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }

    #restaurant, #store {
        width: 100%;
        margin-top: 10px;
    }

    #store {
        max-height: none;
        overflow-y: visible;
    }

    h2 {
        font-size: 16px;
    }

    button {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }

    #time-display {
        font-size: 14px;
    }

    .table {
        min-height: 80px;
    }

    .table-customer {
        width: 36px;
        height: 36px;
    }

    #pond-visual {
        font-size: 40px;
    }
}

/* ---- Sparkline (E4) ---- */
#money-sparkline {
    border: 1px solid var(--space4);
    border-radius: 3px;
    background: var(--space6);
    vertical-align: middle;
    flex-shrink: 0;
}

/* ---- Tooltip (E2) ---- */
#game-tooltip {
    position: fixed;
    background: rgba(8, 8, 18, 0.96);
    color: #ddd;
    border: 1px solid var(--space4);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 11px;
    max-width: 220px;
    line-height: 1.5;
    pointer-events: none;
    z-index: 300;
    white-space: pre-wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* ---- Toasts (E3) ---- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 250;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    pointer-events: none;
}

.game-toast {
    padding: 8px 14px;
    border-radius: 5px;
    font-size: 13px;
    max-width: 260px;
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.game-toast.toast-in  { opacity: 1; transform: translateX(0); }
.game-toast.toast-out { opacity: 0; transform: translateX(16px); }

.toast-warn    { background: rgba(130, 45, 0, 0.93); border-left: 3px solid #d06010; }
.toast-info    { background: rgba(15, 65, 130, 0.93); border-left: 3px solid #3a80d0; }
.toast-success { background: rgba(15, 90, 35, 0.93); border-left: 3px solid #30b050; }

/* ---- Stats Tab (D5) ---- */
.stats-section {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--space4);
}

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

.stats-header {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--space1);
    opacity: 0.7;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stats-row:last-child {
    border-bottom: none;
}

/* ---- Offline Modal (D6) ---- */
#offline-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.offline-box {
    background: var(--space7);
    border: 4px solid var(--space3);
    border-radius: 10px;
    padding: 30px 36px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.offline-box h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--space1);
}

.offline-time {
    font-size: 32px;
    font-weight: bold;
    color: var(--space3);
    margin: 8px 0 16px;
}

.offline-stat {
    font-size: 14px;
    margin: 6px 0;
}

.offline-note {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 10px;
}

.offline-box button {
    margin-top: 20px;
    font-size: 15px;
    padding: 10px 24px;
}

/* ---- Special Events (D3) ---- */
#event-banner {
    padding: 8px 14px;
    margin-bottom: 8px;
    background: rgba(180, 130, 0, 0.18);
    border: 2px solid #b8960a;
    border-radius: 5px;
    font-size: 13px;
    text-align: center;
    animation: pulse 2s infinite;
}

.event-timer {
    font-weight: bold;
    color: #e8b000;
    margin-left: 6px;
}

/* Inspector minigame overlay */
#inspector-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.78);
    z-index: 10;
    border-radius: 5px;
}

.inspector-header {
    color: #fff;
    text-align: center;
    padding: 10px 8px 6px;
    font-size: 13px;
    font-weight: bold;
}

#inspector-field {
    position: relative;
    width: 100%;
    height: calc(100% - 44px);
}

.cockroach {
    position: absolute;
    font-size: 28px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
    line-height: 1;
}

.cockroach:hover {
    transform: scale(1.4);
}

/* Celebrity sprite in restaurant */
.celebrity-sprite {
    z-index: 5;
    position: absolute;
}

/* ---- Restaurant tabs (D2) ---- */
#restaurant-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.rest-tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 8px 10px;
    font-size: 13px;
    background: var(--space5);
    border-radius: 5px 5px 0 0;
    margin: 0;
}

.rest-tab-active {
    background: var(--space3) !important;
    font-weight: bold;
}

/* ---- Store tabs (D1) ---- */
#store-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.tab-btn {
    flex: 1;
    padding: 6px;
    font-size: 12px;
    background: var(--space5);
    border-radius: 4px 4px 0 0;
    margin: 0;
}

.tab-active {
    background: var(--space3) !important;
}

/* Prestige button (D1) */
#btn-prestige {
    background: #8b6914;
    color: #fff;
    font-weight: bold;
    margin-top: 8px;
    animation: pulse 2s infinite;
}

#btn-prestige:hover {
    background: #a8821c;
    transform: scale(1.05);
}

/* Master Chef tab panel (D1) */
.prestige-stars-display {
    text-align: center;
    font-size: 16px;
    padding: 10px 0 6px;
    border-bottom: 2px solid var(--space4);
    margin-bottom: 8px;
}

.prestige-stars-display small {
    display: block;
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
}

.prestige-stats {
    font-size: 11px;
    padding: 4px 0 8px;
    border-bottom: 2px solid var(--space4);
    margin-bottom: 8px;
    opacity: 0.9;
}

.meta-upgrades-header {
    margin: 0 0 6px;
    font-size: 13px;
    text-align: center;
    color: var(--space1);
}

.meta-upgrade-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding: 5px;
    background: var(--space6);
    border-radius: 4px;
}

.meta-upgrade-info {
    flex: 1;
    font-size: 12px;
    line-height: 1.4;
}

.meta-upgrade-info small {
    display: block;
    opacity: 0.8;
    font-size: 10px;
}

.btn-meta-buy {
    white-space: nowrap;
    font-size: 11px !important;
    padding: 4px 8px !important;
    width: auto !important;
    display: inline-block !important;
    background: #8b6914 !important;
    margin: 0;
}

.btn-meta-buy:hover {
    background: #a8821c !important;
    transform: scale(1.05);
}

.btn-meta-locked {
    background: var(--space5) !important;
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-meta-locked:hover {
    transform: none;
}

@media (max-width: 480px) {
    /* E5: Stats bar collapses to icon + number pairs */
    #stats-bar {
        font-size: 12px;
        gap: 4px 12px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 6px 8px;
    }

    #stats-bar p {
        margin: 0;
        white-space: nowrap;
    }

    /* Hide text labels, keep emoji + value */
    .stat-label {
        display: none;
    }

    /* Hide sparkline on very small screens - no room */
    #money-sparkline {
        display: none;
    }

    /* E5: Left column becomes horizontal scroll strip */
    #left-column {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
        max-height: none;
        gap: 8px;
        padding-bottom: 4px;
        /* smooth momentum scroll on iOS */
        -webkit-overflow-scrolling: touch;
    }

    #left-column .screen {
        min-width: 140px;
        max-width: 180px;
        flex-shrink: 0;
    }

    #pond-visual {
        font-size: 28px;
        margin: 6px 0;
    }

    /* E5: Buttons stay 44px tall on mobile */
    button {
        min-height: 44px;
        font-size: 12px;
        padding: 8px 10px;
    }

    #restaurant-area {
        height: 150px;
    }

    .sprite {
        width: 25px;
        height: 25px;
    }

    #tables {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        width: auto;
    }

    .table {
        width: 30px;
        height: 30px;
    }

    .order-display {
        font-size: 10px;
    }

    /* Tighten restaurant tabs on mobile */
    .rest-tab-btn {
        min-width: 80px;
        font-size: 11px;
        padding: 6px 6px;
    }
}
