/* Game shell follows the shared orange / peach / brown site palette. */
html.is-game-page { zoom: 1 !important; }
body.is-game { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body.is-game .site-navbar-header { flex-shrink: 0; }
body.is-game .site-main { max-width: 1120px; flex: 1 0 auto; padding-bottom: 0; border-bottom: 0; z-index: auto; }
body.is-game .site-footer { flex-shrink: 0; margin-top: auto; }
body.is-game.game-expanded > .site-navbar-header, body.is-game.game-expanded > .site-footer { display: none; }
body.game-mobile-portrait .site-main { display: flex; align-items: center; }
body.game-mobile-portrait .game-page-heading, body.game-mobile-portrait .game-quick-actions,
body.game-mobile-portrait .game-help { display: none; }
.game-page { width: 100%; padding: 24px 16px 12px; margin: 0 auto; }
.game-page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.game-back { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; margin-bottom: 8px; }
.game-page-heading h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.2; margin: 0 0 8px; }
.game-page-heading p { margin: 0; color: var(--ink-soft); }
.game-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.25; cursor: pointer; }
.game-button:hover { background: #ffe2bd; color: var(--ink); }
.game-button-primary { background: var(--red); color: #fff; border-color: var(--red-deep); }
.game-button-primary:hover { background: var(--red-deep); color: #fff; }
.game-button:disabled { opacity: .5; cursor: wait; }
.game-button:focus-visible, .game-back:focus-visible, .game-help summary:focus-visible { outline: 3px solid #fff4d9; outline-offset: 3px; box-shadow: 0 0 0 5px var(--frame-bg); }
.game-card { position: relative; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px; padding: 12px; box-shadow: var(--shadow-soft); }
.game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 0 12px; }
.game-state { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.game-state-dot { width: 8px; height: 8px; border-radius: 50%; background: #9b5c17; flex: 0 0 auto; }
.game-card.is-ready .game-state-dot { background: #35782c; }
.game-card.has-error .game-state-dot { background: #bb2530; }
.game-toolbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.game-stage { width: 100%; max-width: 1024px; aspect-ratio: 1024 / 600; position: relative; margin: 0 auto; background: #10100d; overflow: hidden; }
#unity-canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; }
#unity-canvas:focus-visible { outline: 2px solid #ffcf68; outline-offset: -2px; }
.game-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #492408; color: #ffe2bd; text-align: center; padding: 24px; }
.game-loading-logo { display: block; width: min(280px, 65%); max-height: min(120px, 30%); object-fit: contain; }
.game-loading p { margin: 0; }
.game-loading progress { display: block; width: min(320px, 80%); height: 10px; border: 0; border-radius: 5px; overflow: hidden; accent-color: #ffb13d; background: #75471f; }
.game-loading progress::-webkit-progress-bar { background: #75471f; }
.game-loading progress::-webkit-progress-value { background: #ffb13d; }
.game-loading small { max-width: 390px; color: #e5bd90; font-size: 12px; }
.game-frame-caption { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; font-size: 12px; color: var(--ink-soft); }
.game-rotate-hint { display: none; }
.game-quick-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 14px; }
.game-quick-actions p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.game-quick-actions .game-button { flex: 0 0 auto; }
.game-help { border: 1px solid var(--line); border-radius: 5px; background: var(--surface); margin-top: 20px; }
.game-help summary { padding: 15px 16px; min-height: 48px; cursor: pointer; font-weight: 600; }
.game-help summary i { margin-right: 6px; }
.game-help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 4px 16px 18px; }
.game-help h2 { font-size: 15px; margin: 0 0 8px; }
.game-help p { font-size: 13px; margin: 0; color: var(--ink-soft); }
body.game-expanded { overflow: hidden; }
.game-orientation {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 16px;
    background: var(--surface);
    color: var(--ink-soft);
    text-align: center;
    touch-action: pan-y;
}
.game-orientation-icon { font-size: 32px; color: var(--ink); transform: rotate(90deg); }
.game-orientation h2 { max-width: 300px; margin: 0; color: var(--ink); font-size: 18px; line-height: 1.4; }
.game-orientation p { margin: 0; max-width: 300px; font-size: 12px; }
.game-card.is-portrait { padding: 0; overflow: hidden; box-shadow: none; }
.game-card.is-portrait .game-toolbar, .game-card.is-portrait .game-frame-caption { display: none; }
.game-card.is-portrait #unity-canvas, .game-card.is-portrait .game-loading { visibility: hidden; }
.game-card.is-mobile .game-frame-caption > span:first-child { display: none; }
.game-card.is-mobile .game-rotate-hint { display: inline; }
.game-card.is-immersive {
    position: fixed;
    left: var(--game-view-left, 0px);
    top: var(--game-view-top, 0px);
    width: var(--game-view-width, 100vw);
    height: var(--game-view-height, 100vh);
    z-index: 1100;
    margin: 0;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    border: 0;
    border-radius: 0;
    background: #10100d;
    overflow: hidden;
}
.game-card.is-immersive .game-stage {
    position: absolute;
    top: var(--game-render-top, 0px);
    left: var(--game-render-left, 0px);
    right: auto;
    bottom: auto;
    width: var(--game-render-width, 100%);
    height: var(--game-render-height, 100%);
    max-width: none;
    aspect-ratio: auto;
    margin: 0;
}
.game-card.is-immersive .game-toolbar {
    position: absolute;
    top: max(6px, env(safe-area-inset-top, 0px));
    right: max(6px, env(safe-area-inset-right, 0px));
    z-index: 5;
    width: auto;
    max-width: none;
    padding: 3px;
    margin: 0;
    border-radius: 5px;
    background: rgb(35 20 8 / 78%);
}
.game-card.is-immersive .game-state, .game-card.is-immersive .game-frame-caption { display: none; }
.game-card.is-immersive .game-toolbar-actions { gap: 2px; }
.game-card.is-immersive .game-button { min-height: 40px; padding: 8px 10px; font-size: 12px; background: transparent; border-color: transparent; color: #fff1cf; }
.game-card.is-immersive .game-button:hover { background: rgb(255 255 255 / 14%); }
.game-card.is-mobile .game-toolbar { display: none !important; }
/* Focusable bridge for the OS keyboard; the game draws the only visible field. */
.game-keyboard-bridge { position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: .01; pointer-events: none; }
#game-keyboard-input { position: absolute; inset: 0; width: 1px; height: 1px; min-width: 0; padding: 0; font-size: 16px; border: 0; outline: 0; }
@supports (height: 100dvh) { .game-card.is-immersive { height: var(--game-view-height, 100dvh); } }
.game-toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: min(500px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 5px; background: #492408; color: #fff1cf; box-shadow: 0 4px 16px rgb(55 25 4 / 20%); z-index: 2100; font-size: 13px; }
.game-install-dialog { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto; padding: 28px; border: 1px solid var(--line-strong); border-radius: 8px; background: #ffdfb7; color: var(--ink); box-shadow: 0 12px 40px rgb(55 25 4 / 25%); }
.game-install-dialog::backdrop { background: rgb(35 17 4 / 65%); }
.game-dialog-close { position: absolute; right: 8px; top: 6px; min-width: 44px; min-height: 44px; padding: 0; border: 0; font-size: 28px; color: var(--ink); background: transparent; cursor: pointer; }
.game-install-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 10px; background: var(--frame-bg); color: #ffcf68; margin-bottom: 16px; font-size: 25px; }
.game-install-dialog h2 { font-size: 22px; line-height: 1.3; padding-right: 12px; margin: 0 0 12px; }
.game-install-dialog p { color: var(--ink-soft); }
.game-install-dialog ol { padding-left: 22px; }
.game-install-dialog li { padding: 5px 0; }
.game-install-dialog .game-install-footnote { font-size: 12px; margin: 18px 0; }
.game-install-dialog form:last-child .game-button { width: 100%; }
.game-noscript { padding: 16px; background: var(--surface); border: 1px solid var(--line-strong); }
.game-page [hidden], .game-install-dialog[hidden], #game-toast[hidden], .game-loading [hidden] { display: none !important; }
@media (max-width: 767px) {
    .game-page { padding: 16px 12px 8px; }
    .game-page-heading { flex-direction: column; align-items: stretch; gap: 14px; }
    .game-page-heading h1 { font-size: 24px; }
    .game-page-heading p { font-size: 13px; }
    .game-card { padding: 8px; }
    .game-toolbar { flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
    .game-toolbar-actions { margin-left: auto; }
    .game-toolbar-actions .game-button { font-size: 12px; padding: 8px 10px; }
    .game-state { font-size: 12px; }
    .game-loading { padding: 12px; gap: 8px; }
    .game-loading-logo { max-height: 80px; }
    .game-loading p { font-size: 12px; }
    .game-loading small { display: none; }
    .game-frame-caption > span:first-child { display: none; }
    .game-rotate-hint { display: inline; }
    .game-quick-actions { align-items: stretch; flex-direction: column; gap: 12px; }
    .game-quick-actions .game-button { align-self: flex-start; }
    .game-help-grid { grid-template-columns: 1fr; gap: 20px; }
    .game-card.is-immersive .game-toolbar { flex-wrap: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .game-page *, .game-install-dialog * { transition: none !important; scroll-behavior: auto !important; } }
