:root {
    --bg-0: #12100e;
    --bg-1: #1c1813;
    --wood: #6b4a2b;
    --wood-light: #a9743f;
    --gold: #e0a96d;
    --cream: #f3e9dc;
    --text: #ede4d8;
    --text-dim: #b6a690;
    --x-color: #e8e2d6;   /* light marble */
    --o-color: #8a3b2e;   /* dark-red wood */
    --card: #221c16;
    --border: rgba(224, 169, 109, 0.18);
    --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 700px at 50% -10%, rgba(224, 169, 109, 0.10), transparent 60%),
        radial-gradient(900px 600px at 90% 110%, rgba(138, 59, 46, 0.12), transparent 55%),
        linear-gradient(160deg, var(--bg-1), var(--bg-0));
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Header ---------- */
header.site {
    position: relative;
    z-index: 20;
    width: 100%;
    max-width: 1040px;
    padding: 28px 24px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.brand .mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    padding: 6px;
    background: linear-gradient(145deg, #2c241c, #15110d);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.brand .mark span {
    border-radius: 50%;
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.5), inset 0 2px 2px rgba(255,255,255,0.25);
}
.brand .mark span:nth-child(1) { background: radial-gradient(circle at 35% 30%, #fff, #cfc6b8); }
.brand .mark span:nth-child(2) { background: radial-gradient(circle at 35% 30%, #b4543f, #5e241a); }
.brand .mark span:nth-child(3) { background: radial-gradient(circle at 35% 30%, #9a6a3a, #4a2f17); }
.brand .mark span:nth-child(4) { background: radial-gradient(circle at 35% 30%, #3a4452, #10141b); }

.brand .name {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 19px;
    letter-spacing: 0.2px;
    line-height: 1.1;
}
.brand .name small {
    display: block;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-top: 2px;
}

.header-nav {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 2px;
    min-width: 0;
}
.header-nav a {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    padding: 7px 9px;
    border-radius: 999px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.header-nav a:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.lang-switch {
    font-family: 'Inter', sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    flex: 0 0 auto;
    color: var(--text-dim);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 26px 7px 10px;
    margin-left: 4px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23b6a690'%3E%3Cpath d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 14px;
    transition: all 0.2s ease;
}
.lang-switch:hover {
    color: var(--text);
    border-color: var(--gold);
}
.lang-switch option {
    color: #1c1813;
}

/* ---------- Hero ---------- */
.hero {
    position: absolute;
}

/* ---------- Game frame ---------- */
.stage {
    width: 100%;
    max-width: 1040px;
    min-height: 100vh;
    margin-top: -81px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#unity-container.unity-desktop {
    position: relative;
    margin: 0 auto;
    width: min(clamp(320px, calc((100vh - 231px) * 1.6), 960px), calc(100vw - 48px));
    max-width: 100%;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden;
}
/* keep aspect ratio responsive */
#unity-container.unity-desktop .canvas-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 960 / 600;
    background: #231F20;
}
#unity-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    background: #231F20;
}

/* ---------- Loading overlay ---------- */
#unity-loading-bar {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: radial-gradient(600px 400px at 50% 40%, #2a221a, #161210);
    z-index: 5;
}
#unity-logo {
    display: grid;
    grid-template-columns: repeat(3, 26px);
    grid-template-rows: repeat(3, 26px);
    gap: 8px;
    width: auto; height: auto;
    background: none;
}
#unity-logo i {
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.5);
    animation: pop 1.6s ease-in-out infinite;
}
#unity-logo i.x { background: radial-gradient(circle at 35% 30%, #fff, #cfc6b8); }
#unity-logo i.o { background: radial-gradient(circle at 35% 30%, #b4543f, #5e241a); }
#unity-logo i:nth-child(1){animation-delay:0s}
#unity-logo i:nth-child(2){animation-delay:.1s}
#unity-logo i:nth-child(3){animation-delay:.2s}
#unity-logo i:nth-child(4){animation-delay:.3s}
#unity-logo i:nth-child(5){animation-delay:.4s}
#unity-logo i:nth-child(6){animation-delay:.5s}
#unity-logo i:nth-child(7){animation-delay:.6s}
#unity-logo i:nth-child(8){animation-delay:.7s}
#unity-logo i:nth-child(9){animation-delay:.8s}
@keyframes pop {
    0%, 100% { transform: scale(0.7); opacity: 0.35; }
    40% { transform: scale(1); opacity: 1; }
}
.loading-label {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
}
#unity-progress-bar-empty {
    width: 220px;
    height: 6px;
    margin: 0;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
}
#unity-progress-bar-full {
    width: 0%;
    height: 100%;
    margin: 0;
    background: linear-gradient(90deg, var(--wood-light), var(--gold));
    border-radius: 999px;
    transition: width 0.2s ease;
}

/* ---------- Footer bar (fullscreen) ---------- */
#unity-footer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 14px;
    background: rgba(0,0,0,0.25);
    border-top: 1px solid var(--border);
}
#unity-fullscreen-button {
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: url('TemplateData/fullscreen-button.png') no-repeat center / 18px;
    opacity: 0.6;
    transition: all 0.2s ease;
}
#unity-fullscreen-button:hover {
    opacity: 1;
    background-color: rgba(255,255,255,0.07);
}
#unity-warning {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    background: #2a221a;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    z-index: 10;
    display: none;
}

/* ---------- How to play ---------- */
.info {
    width: 100%;
    max-width: 1040px;
    padding: 40px 24px 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
.info .card {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px 22px 24px;
}
.info .card .ic {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 19px;
    margin-bottom: 14px;
    background: linear-gradient(145deg, #2c241c, #15110d);
    border: 1px solid var(--border);
}
.info .card h3 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 17px;
    margin: 0 0 6px;
}
.info .card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-dim);
}

/* ---------- Footer ---------- */
footer.site {
    width: 100%;
    max-width: 1040px;
    padding: 36px 24px 40px;
    margin-top: 24px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}
footer.site a { color: var(--gold); text-decoration: none; }
footer.site a:hover { text-decoration: underline; }

/* ---------- Mobile full-bleed (Unity switches to this) ---------- */
body.mobile {
    display: block;
    background: #231F20;
}
body.mobile header.site,
body.mobile .hero,
body.mobile .info,
body.mobile footer.site { display: none; }

/* Keep .stage rendered on mobile — the game container inside it is
   position:fixed, and a display:none ancestor would remove it (and the
   canvas) from rendering entirely, breaking the game. Just strip its box. */
body.mobile .stage { padding: 0; margin: 0; max-width: none; }

#unity-container.unity-mobile {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.unity-mobile #unity-canvas { width: 100%; height: 100%; }
.unity-mobile #unity-footer { display: none; }
.unity-mobile .canvas-wrap { aspect-ratio: auto; width: 100%; height: 100%; }

@media (max-width: 760px) {
    .info { grid-template-columns: 1fr; }
    header.site {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding-top: 20px;
    }
    .header-nav { justify-content: flex-start; margin-left: -13px; }
}
