/* Tidy Nook — soothing night-time tidying game. Night-warm theme over the
   shared game-chrome wrapper (same page structure as the other games). */

body {
    background-color: #10141f;
}

.game-wrapper {
    position: relative;
    max-width: 1100px;
    margin: 1.25rem auto 2.5rem;
    padding: 0 12px;
}

.game-header-integrated {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #1a2338;
    border: 1px solid #2c374e;
    border-radius: 12px 12px 0 0;
    padding: 10px 14px;
}

.game-logo {
    font-weight: 650;
    letter-spacing: 0.06em;
    color: #e7dfd1;
    font-size: 1.15rem;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.moon-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e7d9c3;
    background: rgba(231, 217, 195, 0.10);
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    white-space: nowrap;
}

.mute-btn {
    background: rgba(231, 217, 195, 0.08);
    color: #e7dfd1;
    border: 1px solid rgba(231, 217, 195, 0.18);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    min-height: 34px;
}

.mute-btn:hover {
    background: rgba(231, 217, 195, 0.16);
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 70vh; /* fallback for browsers without dvh */
    height: max(430px, min(calc(100dvh - 220px), 860px));
    background: #131a2b;
    border: 1px solid #2c374e;
    border-top: none;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    --chrome-accent: #c77b5a;
    --chrome-bg: rgba(22, 28, 44, 0.65);
    --chrome-panel-bg: #161c2c;
}

.canvas-container canvas#nook {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

@supports (padding: max(0px)) {
    .game-wrapper {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

.canvas-container:fullscreen,
.canvas-container:-webkit-full-screen {
    height: 100%;
    border: none;
    border-radius: 0;
}

/* ---- Overlay panels ---- */

.tn-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    background: rgba(10, 13, 24, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    overflow-y: auto;
}

.tn-panel {
    background: rgba(22, 28, 44, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(231, 217, 195, 0.12);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(6, 8, 16, 0.5);
    padding: 24px 20px;
    width: min(420px, 100%);
    max-height: 100%;
    overflow-y: auto;
    color: #e7dfd1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: auto;
}

.tn-panel h2 {
    font-size: 26px;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: #e7dfd1;
    margin: 0 0 6px;
}

.tn-tagline {
    font-size: 16px;
    line-height: 1.5;
    color: #a9a290;
    margin: 0 0 18px;
}

.tn-eyebrow {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #a9a290;
    margin: 0 0 4px;
}

.tn-caption {
    font-size: 16px;
    line-height: 1.5;
    color: #a9a290;
    margin: 8px 0 18px;
}

/* Buttons */

.tn-btn {
    display: inline-block;
    border: none;
    border-radius: 14px;
    padding: 14px 24px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 48px;
    min-width: 130px;
    transition: transform 0.09s ease, background 0.09s ease;
    -webkit-tap-highlight-color: transparent;
}

.tn-btn:active { transform: scale(0.97); }

.tn-btn-primary {
    background: #c77b5a;
    color: #1a1410;
}
.tn-btn-primary:active { background: #b06c4e; }

.tn-btn-secondary {
    background: rgba(231, 217, 195, 0.08);
    color: #e7dfd1;
    border: 1px solid rgba(231, 217, 195, 0.18);
    font-size: 16px;
    font-weight: 500;
    margin: 6px 4px 0;
}
.tn-btn-secondary:active { background: rgba(231, 217, 195, 0.16); }

/* Level select grid */

.tn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 4px 0 6px;
}

.tn-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    border: 1.5px solid rgba(231, 217, 195, 0.10);
    background: linear-gradient(180deg, #131a2b, #232c42);
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.tn-tile canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.tn-tile .tn-tile-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 6px 6px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #e7dfd1;
    background: linear-gradient(180deg, rgba(19, 26, 43, 0), rgba(19, 26, 43, 0.85));
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tn-tile .tn-tile-moon {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.tn-tile.tn-locked {
    filter: brightness(0.55);
    opacity: 0.6;
    cursor: default;
}

.tn-tile.tn-current {
    border-color: rgba(240, 201, 135, 0.5);
}

/* Completion card moon */

.tn-moon-draw {
    width: 54px;
    height: 54px;
    margin: 4px auto 10px;
    display: block;
}

/* Finale stars-in-panel accent */
.tn-finale-line {
    font-size: 18px;
    font-weight: 500;
    color: #e7d9c3;
    margin: 6px 0 16px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tn-btn { transition: none; }
}

@media (max-width: 420px) {
    .tn-panel { padding: 20px 14px; }
    .tn-grid { gap: 9px; }
}
