* { box-sizing: border-box }
:root { color-scheme: dark; font-family: system-ui, "Noto Sans JP", "Yu Gothic", sans-serif; background: #101b19; color: #ebf3e9; --gold: #f7ce69; --muted: #9fb5ab; --panel: #202f2b }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none }
body { background: radial-gradient(ellipse at 50% 20%, #283c32, #101b19 68%) }
button { border: 1px solid #4b6055; border-radius: 9px; background: #253830; color: inherit; font: inherit; font-weight: 700; min-height: 44px; cursor: pointer; touch-action: manipulation }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px }
button[aria-pressed=true] { border-color: var(--gold); color: var(--gold); background: #3f4231 }
button:disabled { opacity: .55; cursor: default }
[hidden] { display: none !important }
#unity-canvas { position: fixed; left: -64px; top: 0; width: 32px; height: 32px; pointer-events: none }
#shell { --safe-top: max(8px, env(safe-area-inset-top)); --safe-bottom: max(8px, env(safe-area-inset-bottom)); height: 100dvh; max-width: 540px; margin: auto; padding: var(--safe-top) max(10px, env(safe-area-inset-right)) var(--safe-bottom) max(10px, env(safe-area-inset-left)); }
.center { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 10px; max-width: 385px; margin: auto; padding-inline: 8px }
#loading { align-items: center; font-weight: 800; letter-spacing: .08em }
#hero { width: 100%; max-height: 25dvh; object-fit: contain }
.edition { font-size: 12px; color: var(--gold); font-weight: 800; letter-spacing: .18em }
h1 { font-size: clamp(53px, 15vw, 94px); line-height: .75; letter-spacing: -.075em; margin: 0; font-weight: 950 }
h1 span, .brand span { color: var(--gold) }
.subtitle { margin: 5px 0 12px; font-weight: 750; color: var(--muted) }
.primary { color: #1b211a; background: var(--gold); border-color: #ffe096 }
.primary span { margin-left: 8px }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.tile { background: var(--panel); border-radius: 9px; padding: 6px 10px; font-size: 12px; color: var(--muted) }
.tile strong { display: block; color: white; font-size: 16px }
#game { height: 100%; display: flex; flex-direction: column; gap: 5px; }
header { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.brand { flex: 1; font-weight: 950; letter-spacing: -.06em; font-size: clamp(15px, 5vw, 25px) }
.brand span { margin-left: .17em }
#clock { font: 900 28px/.9 ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--gold) }
#clock.warning { color: #ff9d56 }
#clock.urgent { color: #ff7665 }
#clock.countdown { animation: pulse-clock 1s infinite }
@keyframes pulse-clock { 30% { transform: scale(1.11) } }
#pause { width: 47px; font-size: 21px }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px }
.metrics div { border-radius: 7px; background: var(--panel); padding: 4px 5px; color: var(--muted); font-size: 11px; white-space: nowrap }
.metrics strong { display: block; color: #fff2d5; font-size: clamp(12px, 4vw, 20px); font-variant-numeric: tabular-nums }
#lesson { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: #313b2e; padding: 3px 5px; border-radius: 7px; font-size: 12px }
#skip { flex: none; padding-inline: 8px }
#board-wrap { flex: 1 1 0; min-height: 0; position: relative; display: grid; place-items: center; }
#board { touch-action: none; user-select: none; display: block; }
.shade { position: absolute; inset: 0; background: #101b19ed; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 9px; border-radius: 12px }
.shade strong { font-size: 25px; margin-bottom: 12px }
.shade button { min-width: 165px; padding-inline: 12px }
#operator-note { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 4px; color: #e2e9dd; font-size: 12px; white-space: pre-line }
#cost { color: var(--gold); white-space: nowrap }
#tools, .actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px }
#tools button { text-align: left; display: grid; grid-template-columns: 24px auto; align-items: center; padding: 3px 4px; column-gap: 4px; font-size: 12px }
#tools button canvas { grid-row: span 2; width: 23px; height: 23px }
#tools button small { font-size: 11px; color: var(--gold) }
.actions button { font-size: 13px }
#rotate[data-target="equipment"] { border-color: var(--gold); color: var(--gold) }
#guide { width: min(420px, calc(100% - 20px)); max-height: min(85dvh, 720px); padding: 14px; border: 1px solid #637a69; border-radius: 13px; background: #202f2b; color: inherit; overscroll-behavior: contain; }
#guide::backdrop { background: #101b19d9 }
#guide header { justify-content: space-between }
#guide h2 { font-size: 21px; margin: 0 }
#guide h3 { font-size: 16px; margin: 12px 0 4px }
#guide p, #guide li { font-size: 13px; line-height: 1.5 }
#guide ul { padding-left: 19px; margin-block: 5px }
#guide form button { padding-inline: 10px }
.port-in { color: #a0f5ff }
.port-out { color: #ffdc77 }
.connection { display: grid; grid-template-columns: 65px 1fr; align-items: center; gap: 8px; }
.connection canvas { width: 65px; height: 65px }
.connection p { margin-block: 4px }
#result { gap: 7px }
#result h2 { margin: 0; font-size: 32px }
.rank { align-self: center; font: 900 55px/.9 ui-monospace, monospace; color: var(--gold); padding: 10px 18px; border: 2px solid var(--gold); border-radius: 12px; transform: rotate(-7deg); animation: stamp .35s ease-out }
@keyframes stamp { from { transform: rotate(-14deg) scale(1.6); opacity: 0 } }
#record { text-align: center; margin: 3px 0 }
#totals, #shipments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px }
#totals div, #shipments div { display: flex; justify-content: space-between; background: var(--panel); border-radius: 5px; padding: 5px 7px; font-size: 12px; }
#totals div:nth-child(4) { color: var(--gold); background: #3f4231 }
#landscape { display: none }
@media (orientation: landscape) and (max-height: 540px) and (hover: none) and (pointer: coarse) {
  #shell { visibility: hidden }
  #landscape { position: fixed; inset: 0; display: grid; place-items: center; font-size: 21px; font-weight: 750 }
}

#shell { display: grid; grid-template-rows: minmax(0, 1fr) 38px; gap: 5px }
#shell > section { width: 100%; min-height: 0 }
#ad-space { display: grid; place-items: center; border: 1px dashed #53695d; border-radius: 7px; background: #182924; color: #9ab1a5; font-size: 12px; }
@media (max-height: 700px) {
  #shell { grid-template-rows: minmax(0, 1fr) 32px; gap: 3px }
  #game { gap: 3px }
  #operator-note { min-height: 28px }
}
