@font-face {
  font-family: Outfit;
  src: url('assets/fonts/outfit-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Plex Thai';
  src: url('assets/fonts/thai-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Plex Thai';
  src: url('assets/fonts/thai-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Plex Thai';
  src: url('assets/fonts/thai-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #0a1322;
  --panel: #111f32;
  --raised: #182b43;
  --line: #263c55;
  --ink: #ecf5ff;
  --muted: #a7bbd0;
  --accent: #75d6f5;
  --primary: #3476df;
  --amber: #f6c58b;
  font-family: Outfit, 'Plex Thai', sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background: radial-gradient(ellipse 780px 500px at 15% -20%, #1d3655 0%, transparent 85%), var(--page);
}

[hidden] { display: none !important; }

button, a { -webkit-tap-highlight-color: transparent; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color .16s, border-color .16s, transform .13s;
}

button:disabled { cursor: default; }

button:not(:disabled):active { transform: translateY(2px); }

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button img, .charge-widget > img, .trip-widget > img {
  display: block;
  width: 20px;
  height: 20px;
  filter: invert(1);
  flex: none;
}

.app {
  max-width: 1380px;
  margin: auto;
  padding: 23px 34px 28px;
}

.header, .header-right, .brand, .wallet {
  display: flex;
  align-items: center;
}

.header {
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 43px;
  height: 43px;
  object-fit: contain;
  border: 1px solid #34567c;
  border-radius: 11px;
  background: #223b5d;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; font-weight: 650; line-height: 1.1; }
.brand small { margin-top: 3px; font-size: 11px; color: var(--muted); }

.header-right { gap: 8px; }

.wallet {
  gap: 7px;
  min-height: 43px;
  padding: 8px 12px;
  border: 1px solid #3f4852;
  border-radius: 10px;
  color: #f8d7a2;
  background: #252a33;
}

.wallet img, .reward-note img {
  width: 19px;
  height: 19px;
  filter: invert(.83) sepia(.35) saturate(1.4);
}

.wallet strong { font-size: 20px; line-height: 1; }
.wallet span { font-size: 11px; color: #d2bc9b; }

.icon-button, .scene-pause, .move-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--raised);
}

.icon-button { width: 43px; height: 43px; border-radius: 10px; }

.icon-button:hover, .scene-pause:not(:disabled):hover, .move-button:not(:disabled):hover {
  background: #24415e;
  border-color: #4e7397;
}

.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 20px 0 18px;
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: clamp(32px, 4.2vw, 57px);
  line-height: 1.02;
  letter-spacing: -.055em;
  font-weight: 650;
}

.page-intro > div > p { color: var(--muted); margin-top: 6px; font-size: 13px; }

.reward-note {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 4px;
  white-space: nowrap;
}

.reward-note strong { color: #f8d7a2; font-size: 15px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 282px;
  gap: 18px;
  align-items: start;
}

.game-card {
  min-width: 0;
  border: 1px solid #334c68;
  border-radius: 19px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 14px 34px #05101c45;
}

.scene {
  position: relative;
  isolation: isolate;
  height: clamp(355px, calc(100svh - 315px), 565px);
  overflow: hidden;
  background: #144f70;
}

.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scene-hud {
  position: absolute;
  inset: 13px 13px auto;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

.charge-widget, .trip-widget, .scene-pause {
  height: 43px;
  background: #0c2135f4;
  color: #eef9ff;
  border: 1px solid #8fbad475;
  border-radius: 10px;
}

.charge-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.charge-widget > div { width: 102px; }

.charge-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  line-height: 1.2;
  color: #c1d9ed;
  margin-bottom: 5px;
}

.charge-label strong { font-size: 12px; color: #eefaff; }

.charge-track {
  height: 5px;
  border-radius: 4px;
  overflow: hidden;
  background: #2b465f;
}

.charge-track > div {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width .18s, background-color .18s;
}

.charge-track[data-level='low'] > div { background: #f4c574; }
.charge-track[data-level='critical'] > div { background: #f28d79; }

.trip-widget {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 11px;
  white-space: nowrap;
}

.trip-widget img { width: 17px; height: 17px; }
.trip-widget strong { font-size: 17px; }
.trip-widget i { width: 1px; height: 14px; background: #42607d; margin: 0 3px; }
#trip-time { min-width: 5ch; text-align: center; font-weight: 600; }
#trip-time[data-urgent] { color: #ffbf92; }
.scene-pause { width: 43px; pointer-events: auto; }
.scene-pause:disabled { opacity: .68; }
.scene-pause img { width: 17px; height: 17px; }

.depth {
  position: absolute;
  right: 13px;
  bottom: 13px;
  padding: 5px 9px;
  border: 1px solid #6fafd460;
  border-radius: 7px;
  background: #082a43ec;
  color: #d7efff;
  font-size: 11px;
  pointer-events: none;
}

.depth strong { color: #fff; font-size: 15px; }

.overlay {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(345px, calc(100% - 36px));
  padding: 17px;
  color: var(--ink);
  border: 1px solid #79a8cd85;
  border-radius: 15px;
  background: #0d1d31f7;
  box-shadow: 0 12px 28px #07122060;
}

.overlay-mascot {
  display: block;
  width: 38px;
  height: 38px;
  background: #21395a;
  border-radius: 9px;
  margin-bottom: 7px;
}

.overlay h2 { font-size: 20px; font-weight: 600; line-height: 1.4; }
.overlay p { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 6px 0 13px; }

.start-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 43px;
  border: 1px solid #6398ed;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.start-button:not(:disabled):hover { background: #4888ed; }
.start-button:disabled { color: #b3c4d6; background: #283d57; border-color: #3b5270; }

.controls {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  grid-template-areas: 'status status' 'move actions';
  gap: 12px 10px;
  padding: 13px 14px 15px;
  border-top: 1px solid #35536e;
}

.control-caption {
  grid-area: status;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 19px;
}

.control-caption > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 1px 9px; }
.control-caption strong { font-size: 13px; font-weight: 600; }
.control-caption #status-help { color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; flex: none; margin-top: 7px; background: var(--accent); border-radius: 50%; }
.controls[data-action='paused'] .status-dot { background: #7b8fa5; }
.controls[data-action='hooked'] .status-dot { box-shadow: 0 0 9px #75d6f580; }

.move-controls {
  grid-area: move;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.move-button { border-radius: 10px; touch-action: none; user-select: none; }
.move-button img { width: 18px; height: 18px; }
.move-button:disabled { opacity: .6; }

.action-buttons {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-button {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  text-align: left;
  border-radius: 10px;
  border: 1px solid #415f81;
  background: #1b3550;
  touch-action: none;
  user-select: none;
}

.action-button > img { width: 24px; height: 24px; }
.action-button span { min-width: 0; }
.action-button strong, .action-button small { display: block; }
.action-button strong { font-size: 15px; font-weight: 600; }
.action-button small { font-size: 10px; opacity: .83; margin-top: 2px; line-height: 1.4; }
.action-button kbd { margin-left: auto; }

kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid #accbeb52;
  border-radius: 4px;
  font: 10px Outfit, sans-serif;
  line-height: 1;
  color: inherit;
}

.drop-button:not(:disabled) { background: var(--primary); border-color: #6094ec; color: #fff; }
.drop-button:not(:disabled):hover { background: #4386eb; }
.drop-button.is-held:not(:disabled) { background: #224f95; border-color: #87b7ff; box-shadow: inset 0 2px 7px #0c2e69; }
.reel-button:not(:disabled):hover { background: #284968; }

.reel-button.has-catch:not(:disabled), .reel-button.has-scrap:not(:disabled) {
  background: var(--accent);
  color: #102742;
  border-color: #a4edff;
}

.reel-button.has-scrap:not(:disabled) { background: var(--amber); border-color: #ffdec0; color: #372716; }
.reel-button.has-catch img, .reel-button.has-scrap img { filter: none; }
.reel-button.has-catch:not(:disabled):hover { background: #a1eaff; }
.reel-button.has-scrap:not(:disabled):hover { background: #ffd4a5; }

.action-button:disabled {
  background: #152438;
  color: #9fb3c9;
  border-color: #2a3d53;
}

.action-button:disabled img { opacity: .45; }
.action-button:disabled kbd { opacity: .55; }

.sidebar { display: grid; gap: 11px; }

.collection-panel, .trip-panel, .field-note {
  padding: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.section-heading, .dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-heading { margin-bottom: 10px; }
.section-heading h2 { font-size: 17px; font-weight: 600; }
.collection-progress { font-size: 12px; color: var(--accent); white-space: nowrap; }

.part-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

.part-cell {
  min-width: 0;
  padding: 7px 4px;
  text-align: center;
  border: 1px solid #315070;
  border-radius: 8px;
  background: #1d344e;
}

.part-portrait { display: block; width: 100%; height: 39px; object-fit: contain; margin-bottom: 3px; }
.part-cell.locked { background: #16263a; border-color: #2a4059; }
.part-cell.locked .part-portrait { opacity: .63; filter: saturate(.45); }
.part-cell span { display: block; font-size: 11px; color: #cfdeee; }
.part-cell small { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }

.text-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0 0;
  background: none;
  font-size: 11px;
  color: var(--accent);
}

.text-button:hover { color: #c0f1ff; }
.text-button img { width: 13px; height: 13px; }

.trip-panel { display: flex; align-items: flex-start; gap: 8px; }
.panel-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--raised); }
.panel-icon img, .field-note h3 img { width: 18px; height: 18px; filter: invert(1); }
.panel-label { color: var(--accent); font-size: 10px; }
.trip-panel h3 { font-size: 14px; margin: 2px 0; font-weight: 600; }
.trip-panel .muted { font-size: 11px; color: var(--muted); line-height: 1.6; }

.field-note h3 { display: flex; align-items: center; gap: 6px; color: var(--amber); font-size: 13px; }
.field-note h3 img { width: 15px; height: 15px; opacity: .75; }
.field-note p { font-size: 11px; color: var(--muted); margin-top: 4px; }
.scrap-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.scrap-example { display: grid; justify-items: center; padding: 4px; border-radius: 6px; background: #16263a; color: var(--muted); }
.scrap-example img { width: 100%; height: 32px; object-fit: contain; }
.scrap-example small { font-size: 11px; font-weight: 600; line-height: 1.1; }
.scrap-example[data-penalty='true'] small { color: var(--amber); }

dialog {
  width: min(540px, calc(100% - 26px));
  max-height: calc(100svh - 32px);
  padding: 18px;
  background: var(--panel);
  border: 1px solid #466584;
  color: var(--ink);
  border-radius: 16px;
}

dialog::backdrop { background: #050e1bc9; backdrop-filter: blur(3px); }
.dialog-heading h2 { font-size: 22px; }
.dialog-subtitle { margin: 9px 0 13px; font-size: 12px; color: var(--muted); }
.dialog-subtitle strong, .book-bottom strong { color: var(--accent); }
.book-grid { gap: 8px; }
.book-grid .part-portrait { height: clamp(43px, 13vw, 78px); }
.book-bottom { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 11px; font-size: 12px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.scene.is-paused canvas { filter: saturate(.72); }
.wallet.bump { animation: wallet-bump .36s ease; }
@keyframes wallet-bump { 45% { transform: scale(1.06); background: #4b4235; } }

@media (max-width: 1000px) {
  .app { padding-inline: 18px; }
  .layout { grid-template-columns: minmax(0, 1fr) 228px; gap: 13px; }
  .controls { grid-template-columns: 96px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .app { max-width: 650px; }
  .layout { display: block; }
  .sidebar { display: none; }
}

@media (max-width: 520px) {
  .app { padding: 10px 10px 15px; }
  .header { padding-bottom: 10px; }
  .brand { gap: 6px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 9px; }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 9px; }
  .header-right { gap: 4px; }
  .icon-button { width: 40px; height: 40px; border-radius: 9px; }
  .wallet { min-height: 40px; padding: 6px 7px; gap: 4px; }
  .wallet strong { font-size: 17px; }
  .wallet span { display: none; }
  .wallet img { width: 16px; height: 16px; }
  .page-intro { margin: 13px 0 11px; align-items: center; gap: 4px; }
  .page-intro > div > p { font-size: 11px; margin-top: 4px; }
  .reward-note { display: grid; gap: 0; justify-items: end; font-size: 9px; padding-bottom: 0; }
  .reward-note strong { font-size: 14px; }
  .reward-note img { display: none; }
  .game-card { border-radius: 14px; }
  .scene { height: clamp(315px, calc(100svh - 250px), 450px); }
  .scene-hud { inset: 8px 8px auto; gap: 5px; }
  .charge-widget, .trip-widget, .scene-pause { height: 39px; }
  .charge-widget { gap: 5px; padding: 0 7px; }
  .charge-widget > div { width: 77px; }
  .charge-widget > img { width: 17px; height: 17px; }
  .charge-label { font-size: 9px; }
  .trip-widget { gap: 4px; padding: 0 6px; font-size: 10px; }
  .trip-widget i { margin: 0 1px; }
  .scene-pause { width: 39px; }
  .overlay { left: 10px; bottom: 10px; width: calc(100% - 20px); padding: 12px; }
  .overlay-mascot { float: right; width: 35px; height: 35px; margin: 0 0 4px 8px; }
  .overlay h2 { font-size: 17px; }
  .overlay p { font-size: 11px; margin: 4px 0 10px; }
  .controls {
    grid-template-columns: minmax(0, 1fr) 92px;
    grid-template-areas: 'status move' 'actions actions';
    align-items: center;
    padding: 9px 9px 11px;
    gap: 7px;
  }
  .control-caption { gap: 6px; }
  .control-caption > div { display: block; }
  .control-caption strong { display: block; font-size: 12px; line-height: 1.35; }
  .control-caption #status-help { display: block; font-size: 10px; line-height: 1.35; }
  .move-controls { gap: 4px; }
  .move-button { min-height: 44px; }
  .action-button { min-height: 57px; padding: 6px 8px; gap: 6px; }
  .action-button > img { width: 20px; height: 20px; }
  .action-button strong { font-size: 14px; }
  kbd { display: none; }
}

@media (max-width: 360px) {
  .app { padding-inline: 7px; }
  .brand strong { font-size: 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .trip-widget img { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.c1-game-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; padding: .5rem 0; }
.c1-game-link { color: #d6ebff; }
