:root {
    --ink: #2a1408;
    --paper: #f3dfc1;
    --sand: #d8b57a;
    --dune: #b8874a;
    --clay: #8a4a28;
    --oasis: #0f6e62;
    --pool: #1ea7a0;
    --sun: #f2b14a;
    --night: #1c120c;
    --line: rgba(42, 20, 8, 0.14);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: Outfit, "Avenir Next", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(242, 177, 74, 0.45), transparent 55%),
        linear-gradient(180deg, #f7c77a 0%, #e8b56a 28%, #c8884a 72%, #8d4d2a 100%);
    line-height: 1.5;
}

.sand-grain {
    pointer-events: none;
    position: fixed;
    inset: 0;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
    z-index: 0;
}

.site-header, .site-main, .site-footer { position: relative; z-index: 1; }

.site-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 22px 7vw 8px;
}

.brand {
    font-family: Fraunces, Georgia, serif;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.05rem;
}

.brand-mark { color: var(--oasis); margin-right: 6px; }

.nav { display: flex; gap: 22px; }

.nav-link {
    color: var(--ink);
    text-decoration: none;
    font-size: 0.95rem;
    opacity: 0.72;
}

.nav-link.is-active,
.nav-link:hover { opacity: 1; }

.site-main { padding: 18px 7vw 64px; }

.hero {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 36px;
    align-items: end;
    padding: 28px 0 46px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.74rem;
    margin: 0 0 10px;
    color: var(--clay);
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.15; margin: 0 0 12px; }

.hero-copy { min-width: 0; }

h1 { font-size: clamp(2.1rem, 7vw, 4.4rem); max-width: 14ch; }

.lead { max-width: 42ch; font-size: 1.08rem; margin: 0; }

.stat-row { display: flex; gap: 28px; margin-top: 28px; }

.stat strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 1.8rem; }

.stat span { font-size: 0.82rem; opacity: 0.7; }

.hero-panel, .game-shell, .board-wrap, .rules article {
    background: color-mix(in srgb, var(--paper) 86%, white);
    border: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(80, 36, 8, 0.12);
}

.hero-panel { padding: 22px 24px; }

.mini-board { list-style: none; padding: 0; margin: 16px 0; }

.mini-board li {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.place { color: var(--oasis); font-weight: 600; }

.text-link, .btn {
    color: var(--oasis);
    font-weight: 600;
    text-decoration: none;
}

.btn, .overlay button, .overlay form button, .ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    cursor: pointer;
    background: var(--oasis);
    color: #f4fff8;
    padding: 12px 18px;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
}

.game-shell { padding: 22px; }

.game-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 16px;
}

.game-head p { margin: 0; opacity: 0.7; }

.hud { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

.hud-item span { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; }

.hud-item b { font-family: Fraunces, Georgia, serif; font-size: 1.25rem; }

.bar {
    width: 120px;
    height: 8px;
    background: rgba(42, 20, 8, 0.12);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 6px;
}

.bar i {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #c45c2a, var(--pool));
}

.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 8px 12px;
}

.stage {
    position: relative;
    background: #c48a45;
    overflow: hidden;
    border-radius: 6px;
}

#oasis-canvas {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
    background: rgba(28, 18, 12, 0.48);
    color: #f6e6c8;
}

.overlay.is-hidden { display: none; }

.overlay-kicker {
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.72rem;
    margin: 0 0 8px;
    color: var(--sun);
}

.overlay h3 { color: #fff8ea; font-size: clamp(1.6rem, 4vw, 2.4rem); }

.overlay form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

.overlay input {
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    min-width: 220px;
    font: inherit;
}

.end-score { font-size: 1.15rem; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    list-style: none;
    padding: 14px 4px 0;
    margin: 0;
    font-size: 0.86rem;
}

.legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
    vertical-align: middle;
}

.lg-water { background: #1aa6b8; border-radius: 99px; }
.lg-mirage { background: #c9d8dc; }
.lg-oasis { background: #157d8c; }
.lg-bug { background: #2a1a12; }
.lg-cactus { background: #2f7a43; }

.pad { display: none; margin-top: 14px; text-align: center; }

.pad button, .pad-mid button {
    width: 64px;
    height: 48px;
    margin: 4px;
    border: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--paper) 70%, var(--dune));
    font-size: 1.2rem;
    cursor: pointer;
}

.page-intro { max-width: 640px; padding: 20px 0 28px; }

.board-wrap { padding: 8px 8px 24px; overflow-x: auto; }

.board { width: 100%; border-collapse: collapse; }

.board th, .board td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.board th { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; }

.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }

.rules article { padding: 20px; }

.rules p { margin: 0; }

.site-footer {
    padding: 0 7vw 28px;
    opacity: 0.7;
    font-size: 0.9rem;
}

.page-rebuild .site-main {
    display: flex;
    align-items: center;
    min-height: calc(100vh - 140px);
}

.rebuild {
    width: min(720px, 100%);
    padding: 28px 0 40px;
}

.rebuild h1 {
    max-width: none;
    font-size: clamp(1.85rem, 6.4vw, 3rem);
}

.rebuild-mark {
    position: relative;
    width: 96px;
    height: 72px;
    margin: 8px 0 22px;
}

.rebuild-sun {
    position: absolute;
    left: 8px;
    top: 6px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sun);
    box-shadow: 0 0 28px rgba(242, 177, 74, 0.55);
}

.rebuild-crane {
    position: absolute;
    right: 10px;
    bottom: 4px;
    width: 44px;
    height: 52px;
    background:
        linear-gradient(var(--ink), var(--ink)) 22px 0 / 4px 52px no-repeat,
        linear-gradient(var(--clay), var(--clay)) 8px 10px / 36px 4px no-repeat,
        linear-gradient(var(--oasis), var(--oasis)) 34px 14px / 3px 28px no-repeat;
}

.rebuild-note {
    margin: 22px 0 0;
    font-size: 0.95rem;
    opacity: 0.72;
}

@media (max-width: 860px) {
    .hero, .rules { grid-template-columns: 1fr; }
    .game-head { flex-direction: column; align-items: start; }
    .pad { display: block; }
    .board th, .board td { padding: 10px 8px; font-size: 0.9rem; }
}
