:root {
  color-scheme: dark;
  --mint: #d7f5bf;
  --line: #073335;
  --ink: #f0ffeb;
  --ink-soft: #baeec9;
  --panel-border: #072f31;
  --panel-shadow: #041e20;
  --ice-panel:
    linear-gradient(122deg, transparent 0 38%, rgba(215, 245, 191, .14) 38% 54%, transparent 54%),
    linear-gradient(28deg, transparent 0 58%, rgba(145, 238, 224, .11) 58% 72%, transparent 72%),
    linear-gradient(160deg, #1b6b66f2 0%, #13504ef2 52%, #0d3c3cf2 100%);
  --ice-card:
    linear-gradient(118deg, transparent 0 44%, rgba(220, 252, 235, .14) 44% 62%, transparent 62%),
    linear-gradient(180deg, #247c76f2 0%, #175956f2 100%);
  /* Tombol sekunder: toska terang yang menonjol dari panel */
  --aqua-btn:
    linear-gradient(115deg, transparent 0 42%, rgba(255, 255, 255, .16) 42% 60%, transparent 60%),
    linear-gradient(180deg, #3fae9f 0%, #25877e 55%, #19665f 100%);
  --aqua-btn-soft:
    linear-gradient(115deg, transparent 0 42%, rgba(255, 255, 255, .13) 42% 60%, transparent 60%),
    linear-gradient(180deg, #2f9286 0%, #1f726a 55%, #165753 100%);
  /* Pilihan belum aktif: slot gelap yang terlihat "tertekan" */
  --chip:
    linear-gradient(115deg, transparent 0 42%, rgba(205, 248, 224, .07) 42% 60%, transparent 60%),
    linear-gradient(180deg, #0b3938 0%, #0f4846 55%, #135451 100%);
  /* Aksi utama & pilihan aktif: emas cahaya matahari / pasir */
  --mint-btn:
    linear-gradient(115deg, transparent 0 42%, rgba(255, 255, 255, .34) 42% 60%, transparent 60%),
    linear-gradient(180deg, #ffe59a 0%, #f7c04a 55%, #e39a2c 100%);
  --gold-edge: #6a3c06;
  --gold-ink: #3a1d02;
  --poly-a: polygon(0 4%, 100% 0, 98.5% 96%, 1.5% 100%);
  --poly-b: polygon(1.5% 0, 99% 4%, 100% 100%, 0 96%);
  --poly-sq: polygon(2% 4%, 98% 0, 100% 97%, 0 100%);
  font-family: system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: #136c70;
  color: #f2fbff;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #eaffb7;
  outline-offset: 3px;
}

button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

header,
.hud,
.quiz,
.help,
#minimap {
  user-select: none;
  -webkit-user-select: none;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  outline: 0;
}

#world.dragging {
  cursor: grabbing;
}

.shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #032e332f, transparent 28%, transparent 60%, #052a3547);
}

/* ===== Topbar & Explore Mode ===== */
.topbar {
  position: fixed;
  left: 26px;
  right: 26px;
  top: max(18px, env(safe-area-inset-top));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  pointer-events: none;
}

.topbar>* {
  pointer-events: auto;
}

.actions {
  display: flex;
  gap: 8px;
  min-width: 160px;
  justify-content: flex-end;
}

.icon-button {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 41px;
  height: 41px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  filter: drop-shadow(0 3px 0 var(--panel-shadow));
  transition: transform .1s;
}

.icon-button::before,
.icon-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: var(--poly-sq);
  background: var(--panel-border);
}

.icon-button::after {
  inset: 2px;
  z-index: -1;
  background: var(--ice-panel);
}

.icon-button:hover::after {
  filter: brightness(1.06);
}

.icon-button:active {
  transform: translateY(2px);
}

.icon-button[aria-pressed=true] {
  color: var(--gold-ink);
}

.icon-button[aria-pressed=true]::after {
  background: var(--mint-btn);
}

#sound[aria-pressed=true],
#music[aria-pressed=true] {
  color: #ffd3c8;
}

#sound[aria-pressed=true]::after,
#music[aria-pressed=true]::after {
  background: linear-gradient(180deg, #6e2a23, #4a1814);
}

#sound[aria-pressed=true]::before,
#music[aria-pressed=true]::before {
  background: #2e0d0a;
}

.scene-title {
  position: fixed;
  top: 126px;
  left: 38px;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 2px 12px #052a3dcc;
}

.eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #e6f7ffe6;
  display: flex;
  gap: 10px;
  align-items: center;
}

.eyebrow::before {
  content: "";
  height: 2px;
  width: 21px;
  background: #b6ecffcc;
}

.scene-title h1 {
  font-size: 47px;
  font-weight: 450;
  letter-spacing: -2px;
  line-height: 1.04;
  margin: 14px 0 9px;
}

.scene-title h1 small {
  font-size: 11px;
  letter-spacing: 1px;
  opacity: .85;
  font-weight: 700;
  margin-left: 13px;
  vertical-align: middle;
}

.scene-title p {
  font-size: 15px;
  color: #e9f9ffe6;
  margin: 0;
}

.guide {
  position: fixed;
  right: 36px;
  top: 134px;
  font-size: 12px;
  color: #eaf9ffe0;
  text-shadow: 0 2px 8px #052a3dcc;
  pointer-events: none;
}

.tag {
  position: fixed;
  z-index: 2;
  transform: translate(-50%, -100%);
  padding: 6px 11px;
  border: 2px solid var(--panel-border);
  background: var(--ice-card);
  color: var(--ink);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 0 var(--panel-shadow);
}

.tag::after {
  content: "";
  width: 7px;
  height: 7px;
  background: #175956;
  border-right: 2px solid var(--panel-border);
  border-bottom: 2px solid var(--panel-border);
  position: absolute;
  bottom: -5px;
  left: calc(50% - 4px);
  transform: rotate(45deg);
}

.tag small {
  font-size: 8.5px;
  color: var(--mint);
  margin-left: 7px;
}

.paused {
  position: fixed;
  right: 36px;
  top: 165px;
  border: 2px solid var(--panel-border);
  background: var(--ice-card);
  color: var(--ink);
  padding: 6px 11px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 4px;
  box-shadow: 0 3px 0 var(--panel-shadow);
  z-index: 2;
}

.dock {
  position: fixed;
  z-index: 4;
  left: 50%;
  transform: translateX(-50%);
  bottom: 94px;
  width: min(1060px, calc(100% - 56px));
  padding: 15px 18px 16px;
  display: flex;
  align-items: stretch;
  gap: 20px;
  border: 2.5px solid var(--panel-border);
  background: var(--ice-panel);
  color: var(--ink);
  border-radius: 6px;
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .34), 0 5px 0 var(--panel-shadow), 0 18px 42px rgba(4, 28, 30, .46);
}

.species-group {
  flex: 1.13;
  min-width: 0;
}

.motion-group {
  flex: 1;
  min-width: 0;
  align-self: center;
}

.group-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 2px 9px;
}

.group-label small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--ink-soft);
}

.species-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.species-heading .group-label {
  flex: 1;
  min-width: 0;
  margin: 0;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.species-paging {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.species-paging button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  background: var(--ice-card);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--panel-shadow);
}

.species-paging button svg {
  width: 14px;
  height: 14px;
}

.species-paging button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.species-paging button:disabled {
  opacity: .38;
  cursor: default;
}

.species-list,
.motions {
  display: flex;
  gap: 6px;
}

.species-list {
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #9de8bd55 transparent;
  padding: 3px 3px 8px;
  scroll-snap-type: x proximity;
}

.species-list::-webkit-scrollbar {
  height: 4px;
}

.species-list::-webkit-scrollbar-thumb {
  background: #9de8bd55;
  border-radius: 4px;
}

.species {
  flex: 0 0 142px;
  min-height: 46px;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 6px;
  border: 2px solid var(--panel-border);
  background: var(--aqua-btn-soft);
  color: #f4ffef;
  border-radius: 4px;
  box-shadow: inset 0 1.5px 0 rgba(205, 248, 224, .22), 0 3px 0 var(--panel-shadow);
}

.species:focus-visible {
  outline-offset: -3px;
}

.species canvas {
  width: 55px;
  height: 32px;
  display: block;
  flex-shrink: 0;
}

.species span {
  font-size: 11px;
  line-height: 1.25;
  font-weight: 800;
  text-shadow: 0 1px 0 #052526;
  white-space: nowrap;
}

.species[aria-pressed=true] {
  background: var(--aqua-btn);
  border-color: var(--gold-edge);
  box-shadow: inset 0 0 0 2px #ffd36a, 0 3px 0 var(--panel-shadow);
}

.species:hover,
.motion:hover,
.follow:hover {
  filter: brightness(1.06);
}

.divider {
  width: 2px;
  background: #9de8bd29;
  margin: 4px 0;
}

.motions {
  gap: 6px;
}

.motion {
  position: relative;
  z-index: 0;
  isolation: isolate;
  flex: 1;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  font-size: 10.5px;
  white-space: nowrap;
  filter: drop-shadow(0 3px 0 var(--panel-shadow));
}

.motion::before,
.motion::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: var(--poly-a);
  background: var(--panel-border);
}

.motion:nth-child(even)::before,
.motion:nth-child(even)::after {
  clip-path: var(--poly-b);
}

.motion::after {
  inset: 2px;
  z-index: -1;
  background: var(--chip);
}

.motion svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.motion[aria-pressed=true] {
  color: var(--gold-ink);
  text-shadow: 0 1px 0 rgba(255, 244, 210, .6);
}

.motion[aria-pressed=true]::after {
  background: var(--mint-btn);
}

.follow {
  position: relative;
  z-index: 0;
  isolation: isolate;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  width: 58px;
  flex-shrink: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 9px 4px;
  color: var(--ink);
  font-size: 9.5px;
  white-space: nowrap;
  filter: drop-shadow(0 3px 0 var(--panel-shadow));
}

.follow::before,
.follow::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: var(--poly-sq);
  background: var(--panel-border);
}

.follow::after {
  inset: 2px;
  z-index: -1;
  background: var(--chip);
}

.follow[aria-pressed=true] {
  color: var(--gold-ink);
  text-shadow: 0 1px 0 rgba(255, 244, 210, .6);
}

.follow[aria-pressed=true]::after {
  background: var(--mint-btn);
}

.follow svg {
  width: 18px;
  height: 18px;
}

.journey {
  position: fixed;
  z-index: 4;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 64px));
}

.track {
  height: 20px;
  position: relative;
  display: flex;
  align-items: center;
}

.track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 7px;
  border-radius: 3px;
  border: 2px solid var(--panel-border);
  background: linear-gradient(90deg, #d7f5bf, #5fc2b7 52%, #4aa6e0);
  box-shadow: 0 2px 0 var(--panel-shadow);
}

.track::after {
  content: "";
  position: absolute;
  left: 33.333%;
  right: 33.333%;
  height: 11px;
  border-left: 2px solid #f0ffebcc;
  border-right: 2px solid #f0ffebcc;
  pointer-events: none;
}

.track input {
  position: relative;
  z-index: 1;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  width: 100%;
  height: 24px;
  margin: 0;
  cursor: ew-resize;
  touch-action: none;
}

.track input::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  height: 20px;
  width: 24px;
  border: 2.5px solid var(--panel-border);
  border-radius: 3px;
  background: var(--mint-btn);
  box-shadow: 0 2px 0 var(--panel-shadow);
}

.track input::-moz-range-thumb {
  height: 16px;
  width: 20px;
  border: 2.5px solid var(--panel-border);
  border-radius: 3px;
  background: var(--mint-btn);
}

.track input::-moz-range-track {
  background: transparent;
}

.journey-labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 7px;
  font-size: 9px;
  letter-spacing: .6px;
  color: #edf9e7a6;
}

.journey-labels span:nth-child(2) {
  text-align: center;
}

.journey-labels span:last-child {
  text-align: right;
}

.journey-labels span.active {
  color: #efffe1;
}

/* ===== Loading & Toast ===== */
.loading {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 24px 16px;
  text-align: center;
  background: linear-gradient(155deg, #165e5b, #0c3939);
  color: #f0ffeb;
  transition: opacity .4s;
}

.loading.done {
  opacity: 0;
  pointer-events: none;
}

.loading-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--ice-card);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: 0 3px 0 var(--panel-shadow);
  color: var(--mint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
}

.loading-marlin-wrap {
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: -4px;
}

.loading-marlin-wrap::before {
  content: "";
  position: absolute;
  width: 78%;
  height: 76%;
  border-radius: 999px;
  background: radial-gradient(ellipse at 50% 50%, rgba(145, 238, 224, .2) 0%, rgba(145, 238, 224, .05) 55%, transparent 78%);
  pointer-events: none;
}

#loading-marlin {
  position: relative;
  display: block;
  width: min(340px, 86vw);
  height: auto;
  aspect-ratio: 340 / 128;
  filter: drop-shadow(0 8px 14px rgba(3, 18, 20, .38));
}

.loading h2 {
  font-size: 27px;
  font-weight: 450;
  letter-spacing: -1px;
  margin: 0;
}

.loading p {
  font-size: 12px;
  color: #def5e6ad;
  margin: 0;
}

.loading-progress {
  width: min(296px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 2px;
}

.loading-bar {
  position: relative;
  width: 100%;
  height: 16px;
  padding: 2px;
  border-radius: 999px;
  border: 2px solid var(--panel-border);
  background: linear-gradient(180deg, #062527, #0c3d3c);
  box-shadow: inset 0 2px 5px rgba(2, 14, 15, .75), 0 3px 0 var(--panel-shadow);
  overflow: hidden;
}

.loading-fill {
  position: relative;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe8a3 0%, #f7c04a 58%, #df9324 100%);
  box-shadow: inset 0 1px 0 rgba(255, 250, 224, .75), 0 0 10px rgba(247, 192, 74, .45);
  transition: width .16s ease-out;
  overflow: hidden;
}

.loading-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -55deg,
    rgba(255, 255, 255, .28) 0 8px,
    transparent 8px 16px
  );
  background-size: 22px 100%;
  animation: loading-sheen .9s linear infinite;
}

@keyframes loading-sheen {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 22px 0;
  }
}

.loading-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px;
  font-size: 11.5px;
  color: #cbeed8;
}

.loading-meta b {
  color: #ffe59a;
}

.toast {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  background: var(--ice-panel);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  max-width: min(500px, 88vw);
  text-align: center;
  transition: opacity .2s;
  box-shadow: 0 4px 0 var(--panel-shadow), 0 10px 24px #06212255;
}

.toast.show {
  opacity: 1;
}

/* ===== Modals & Dialogs ===== */
.help {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: #062527a6;
  display: grid;
  place-items: center;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.help-box {
  max-width: 424px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #9de8bd55 transparent;
  border-radius: 6px;
  padding: 12px;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .03) 0 26px, rgba(3, 20, 22, .22) 26px 28px),
    linear-gradient(160deg, #1b6b66f5 0%, #114b49f5 55%, #0a3435f5 100%);
  color: #472a14;
  border: 2.5px solid var(--panel-border);
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .32), 0 6px 0 var(--panel-shadow), 0 22px 54px #031a1c88;
}

.paper-sheet {
  position: relative;
  padding: 16px 16px 15px;
  background: radial-gradient(ellipse at 50% 42%, #fcf2db 0%, #f1dcba 70%, #dec092 100%);
  border: 1.5px solid #967247;
  border-radius: 2px;
  color: #472a14;
  box-shadow: inset 0 0 24px rgba(138, 96, 48, .18), 0 3px 0 #7a5932, 0 8px 18px rgba(3, 20, 22, .38);
}

.paper-sheet::before {
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 22px;
  height: 22px;
  background: linear-gradient(225deg, #124f4d 47%, #8a673e 49%, #f8ebd0 76%, #d4b482 100%);
  box-shadow: -2px 2px 4px rgba(68, 40, 14, .28);
  pointer-events: none;
  z-index: 3;
}

.paper-sheet::after {
  content: "";
  position: absolute;
  bottom: -1.5px;
  left: -1.5px;
  width: 24px;
  height: 24px;
  background: linear-gradient(45deg, #0d3e3e 47%, #8a673e 49%, #f7e8ca 76%, #cfb07e 100%);
  box-shadow: 2px -2px 4px rgba(68, 40, 14, .26);
  pointer-events: none;
  z-index: 3;
}

.help-box .eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 4px 11px;
  background: var(--ice-card);
  border: 2px solid var(--panel-border);
  border-radius: 3px;
  box-shadow: 0 2px 0 var(--panel-shadow);
  color: var(--mint);
  letter-spacing: 1.4px;
}

.help-box .eyebrow::before {
  display: none;
}

.help-box h2 {
  position: relative;
  font-size: 22px;
  font-weight: 500;
  color: #452812;
  text-shadow: 0 1px 0 rgba(255, 250, 238, .85);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #a88358;
}

.help-box h2::before,
.help-box h2::after {
  content: "";
  position: absolute;
  bottom: -3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7a5631;
}

.help-box h2::before {
  left: 0;
}

.help-box h2::after {
  right: 0;
}

.help-box p {
  font-size: 13px;
  line-height: 1.55;
  color: #543319;
  font-weight: 700;
  margin: 0 0 12px;
}

.help-box p code {
  padding: 1px 6px;
  border-radius: 4px;
  background: #4e2f16;
  border: 1.5px solid #2f1a0a;
  font-size: 11.5px;
  color: #fdf1d6;
}

.help-sections {
  display: grid;
  gap: 8px;
  margin-bottom: 11px;
}

.help-item {
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(255, 250, 236, .42);
  border: 1.5px solid #c39e70;
}

.help-item h3 {
  margin: 0 0 3px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .2px;
  color: #452812;
}

.help-box .help-item p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.48;
}

.help-box .help-keys {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
  color: #6b4422;
}

.help-credits {
  display: grid;
  gap: 4px;
  padding: 9px 11px;
  margin-bottom: 12px;
  border-top: 1.5px dashed #a88358;
  border-bottom: 1.5px dashed #a88358;
  background: rgba(168, 131, 88, .12);
  border-radius: 3px;
  font-size: 12px;
}

.help-credits div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.help-credits span {
  color: #704926;
  font-weight: 700;
}

.help-credits b {
  color: #3d200a;
  font-weight: 800;
  text-align: right;
}

.help-credits a {
  color: #165e59;
  text-decoration: underline;
  text-underline-offset: 2.5px;
  text-decoration-thickness: 1.5px;
  transition: color .14s ease;
}

.help-credits a:hover,
.help-credits a:focus-visible {
  color: #0b3d3a;
}

.help-box button,
.reload {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 12px 14px;
  background: transparent;
  color: var(--gold-ink);
  text-shadow: 0 1px 0 rgba(255, 244, 210, .6);
  font-size: 14px;
  font-weight: 800;
  filter: drop-shadow(0 3px 0 var(--panel-shadow));
  transition: transform .08s, filter .12s;
}

.help-box button::before,
.help-box button::after,
.reload::before,
.reload::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: var(--poly-a);
  background: var(--panel-border);
}

.help-box button::after,
.reload::after {
  inset: 2.5px;
  z-index: -1;
  background: var(--mint-btn);
}

.help-box button:hover:not(:disabled)::after,
.reload:hover::after {
  filter: brightness(1.05);
}

.help-box button:active:not(:disabled),
.reload:active {
  transform: translateY(2px);
}

.reload {
  width: auto;
}

.help-box button+button {
  margin-top: 8px;
}

.help-box .ghost {
  color: #f2ffed;
  text-shadow: 0 1.5px 0 #062b2d;
}

.help-box .ghost::after {
  background: var(--aqua-btn-soft);
}

.help-box .ghost:hover::after {
  filter: brightness(1.09);
}

/* ===== Game Mode Visibility & HUD ===== */
body:not([data-mode=play]) :is(.hud, #minimap) {
  display: none;
}

body:is([data-mode=menu], [data-mode=result]) .topbar {
  display: none;
}

body[data-mode=play] .toast {
  top: auto;
  bottom: 72px;
}

.hud {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: max(14px, env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}

.hud-stats {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.hud-box {
  min-width: 156px;
  padding: 10px 26px 11px;
  border: 2.5px solid var(--panel-border);
  border-radius: 5px;
  background: var(--ice-panel);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.04;
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .34), 0 4px 0 var(--panel-shadow), 0 8px 18px #031a1c55;
}

.hud-box b {
  font-size: 42px;
  font-weight: 650;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  color: #f4ffec;
  text-shadow: 0 2px 0 #062b2d;
}

.hud-box small {
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--ink-soft);
  margin-top: 5px;
  text-transform: uppercase;
}

.hud-timebox {
  min-width: 156px;
}

.hud-time {
  font-size: 42px !important;
  font-weight: 700 !important;
  line-height: 1;
}

.hud-time.low {
  color: #ff9e8e !important;
  animation: lowpulse .45s ease-in-out infinite alternate;
}

@keyframes lowpulse {
  to {
    transform: scale(1.1);
  }
}

.hud-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
  filter: drop-shadow(0 3px 0 #5b3e1f) drop-shadow(0 8px 16px rgba(3, 20, 22, .45));
}

.hud-chain {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px 9px 14px;
  border: 2px solid #7a5730;
  border-radius: 2px;
  background: radial-gradient(ellipse at 50% 45%, #fcf2dc 0%, #f1dcba 74%, #dfc090 100%);
  color: #3d200a;
  clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%);
  box-shadow: inset 0 0 16px rgba(138, 96, 48, .18);
  animation: pillin .16s ease-out;
}

.hud-chain::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 15px;
  height: 15px;
  background: linear-gradient(225deg, #7a5730 0 58%, #faf0d7 60%, #d1af7c 100%);
  box-shadow: -2px 2px 4px rgba(58, 34, 12, .28);
  pointer-events: none;
}

.hud-chain canvas {
  width: 68px;
  height: 36px;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 2px rgba(74, 42, 14, .26));
}

.hud-chain span {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.hud-chain small {
  font-size: 10.5px;
  letter-spacing: .4px;
  color: #6b4422;
  font-weight: 800;
  margin-bottom: 2px;
}

.hud-chain b {
  font-size: 17px;
  color: #3d200a;
  text-shadow: 0 1px 0 rgba(255, 251, 240, .75);
  font-weight: 800;
}

.monitor-alert {
  pointer-events: auto;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 10px;
  border-radius: 5px;
  border: 2.5px solid #6b2904;
  background: linear-gradient(150deg, #ffdf6e 0%, #f5a028 100%);
  color: #4a1a00;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 4px 0 #592002, 0 10px 22px #2f090455;
  animation: alertpulse .55s ease-in-out infinite alternate;
}

.monitor-alert:hover {
  filter: brightness(1.06);
}

.monitor-alert-icon {
  display: inline-block;
  color: #7d1b00;
  font-weight: 400;
  font-size: 22px;
  line-height: 1;
  padding: 0 2px;
  text-shadow: 0 1.5px 0 #fff2b2;
  transform: rotate(-8deg);
  animation: alertwiggle .45s ease-in-out infinite alternate;
  flex-shrink: 0;
}

@keyframes alertwiggle {
  from {
    transform: rotate(-10deg) scale(1);
  }

  to {
    transform: rotate(6deg) scale(1.14);
  }
}

.monitor-alert-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px 7px;
  text-align: center;
}

.monitor-alert-text b {
  font-size: 13px;
  color: #451600;
}

.monitor-alert-text small {
  font-size: 11px;
  color: #5c2202;
  font-weight: 800;
}

@keyframes alertpulse {
  to {
    transform: scale(1.03);
    box-shadow: 0 10px 28px #ff7b4755;
  }
}

@keyframes pillin {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(.96);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

#minimap {
  position: fixed;
  z-index: 3;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 28px));
  height: auto;
  aspect-ratio: 600 / 44;
  border: 2.5px solid var(--panel-border);
  border-radius: 5px;
  touch-action: none;
  cursor: pointer;
  background: #0c3b3cc7;
  box-shadow: 0 4px 0 var(--panel-shadow), 0 8px 20px #031a1c55;
}

.pan-hint {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.42s ease;
}

.pan-hint.show {
  opacity: 1;
}

.pan-hint.hide {
  opacity: 0;
}

body:not([data-mode=play]) .pan-hint,
.pan-hint[hidden] {
  display: none;
}

.pan-edge {
  position: fixed;
  top: clamp(96px, 21vh, 156px);
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  transition: transform 0.42s ease;
}

.pan-edge.left {
  left: max(16px, env(safe-area-inset-left));
  transform: translateX(10px);
}

.pan-edge.right {
  right: max(16px, env(safe-area-inset-right));
  transform: translateX(-10px);
}

.pan-hint.show .pan-edge {
  transform: translateX(0);
}

.pan-hint.hide .pan-edge.left {
  transform: translateX(-10px);
}

.pan-hint.hide .pan-edge.right {
  transform: translateX(10px);
}

.pan-edge-label {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(14px, 2vw, 17px);
  letter-spacing: 0.03em;
  line-height: 1.15;
  white-space: nowrap;
  text-align: center;
  color: #ffffff;
  text-shadow: 0 2px 8px #031a1cb8, 0 2px 0 #042224d8;
}

.pan-arrow {
  display: block;
  width: 100%;
  color: #ffffff;
  filter: drop-shadow(0 2px 6px #031a1cb8) drop-shadow(0 1.5px 0 #042224d8);
}

.pan-arrow svg {
  display: block;
  width: 100%;
  height: auto;
}

.pan-arrow.left svg {
  animation: pan-nudge-left 2.1s ease-in-out infinite;
}

.pan-arrow.right svg {
  animation: pan-nudge-right 2.1s ease-in-out infinite;
}

.pan-arrow .pa-drop {
  color: #dcfaff;
  opacity: 0.65;
  transform-box: fill-box;
  transform-origin: center;
  animation: pan-splash 2.1s ease-in-out infinite;
}

.pan-arrow .pa-drop-2 {
  animation-delay: 0.25s;
}

.pan-arrow .pa-drop-3 {
  animation-delay: 0.45s;
}

@keyframes pan-nudge-left {
  0%, 100% {
    transform: translateX(0);
    opacity: 0.86;
  }
  50% {
    transform: translateX(-6px);
    opacity: 1;
  }
}

@keyframes pan-nudge-right {
  0%, 100% {
    transform: translateX(0);
    opacity: 0.86;
  }
  50% {
    transform: translateX(6px);
    opacity: 1;
  }
}

@keyframes pan-splash {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.88);
  }
  50% {
    opacity: 0.96;
    transform: scale(1.06);
  }
}

@media (max-width: 560px) {
  .pan-edge {
    top: clamp(92px, 21vh, 138px);
    gap: 2px;
  }
  .pan-edge.left {
    left: max(10px, env(safe-area-inset-left));
  }
  .pan-edge.right {
    right: max(10px, env(safe-area-inset-right));
  }
  .pan-edge-label {
    font-size: 13px;
  }
}

@media (max-height: 560px) {
  .pan-edge {
    top: max(68px, 16vh);
  }
}

/* ===== Menu, Challenge, Pause & Result Cards ===== */
.game-box {
  max-width: 440px;
}

.menu-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  margin-bottom: 10px;
}

.menu-top .eyebrow {
  margin-bottom: 0;
}

.menu-audio {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.help-box .menu-mute {
  width: auto;
  height: 30px;
  padding: 0 9px;
  margin-top: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  color: #4a2b13;
  text-shadow: none;
  flex-shrink: 0;
}

.help-box .menu-help-btn {
  width: 30px;
  padding: 0;
}

.help-box .menu-mute svg {
  width: 15px;
  height: 15px;
}

.help-box .menu-mute::before,
.help-box .menu-mute::after {
  clip-path: var(--poly-sq);
}

.help-box .menu-mute::after {
  background: linear-gradient(180deg, #f5e5c4, #e1c392);
}

.help-box .menu-mute[aria-pressed=true] {
  color: #ffd3c8;
}

.help-box .menu-mute[aria-pressed=true]::after {
  background: linear-gradient(180deg, #6e2a23, #4a1814);
}

.game-box .eyebrow {
  margin-bottom: 8px;
}

.game-box h2 {
  font-size: 23px;
  letter-spacing: -.4px;
  margin-bottom: 10px;
}

/* ===== Home Instruction Scenario Screen ===== */
.howto-screen {
  border: 2.5px solid var(--panel-border);
  border-radius: 5px;
  background: var(--chip);
  box-shadow: inset 0 3px 12px rgba(3, 18, 20, .55), 0 3px 0 var(--panel-shadow);
  margin: 0 0 13px;
  overflow: hidden;
}

.howto-slides {
  position: relative;
  overflow: hidden;
}

.howto-slide {
  position: relative;
  height: 178px;
  overflow: hidden;
  background: #093233;
  animation: slidefade .24s ease-out;
}

.howto-slide[data-slide="3"].active {
  animation: slidefade .24s ease-out, slideshake .38s linear infinite;
}

@keyframes slideshake {
  0%, 100% {
    transform: translate(0, 0) scale(1.03);
  }
  15% {
    transform: translate(-3px, 2px) scale(1.03);
  }
  30% {
    transform: translate(3px, -2.5px) scale(1.03);
  }
  45% {
    transform: translate(-3.5px, -1.5px) scale(1.03);
  }
  60% {
    transform: translate(2.5px, 2.5px) scale(1.03);
  }
  75% {
    transform: translate(-2px, 1.5px) scale(1.03);
  }
  90% {
    transform: translate(2.5px, -1.5px) scale(1.03);
  }
}

@keyframes slidefade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.slide-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.overlay-quiz .mini-quiz-mock {
  position: absolute;
  right: 22px;
  top: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 2px solid var(--panel-border);
  border-radius: 5px;
  background: var(--ice-panel);
  box-shadow: 0 3px 0 var(--panel-shadow);
}

.mq-timer {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold-edge);
  background: var(--mint-btn);
  color: var(--gold-ink);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.mq-lines {
  display: grid;
  gap: 4px;
}

.mq-lines i {
  display: block;
  width: 44px;
  height: 7px;
  border-radius: 3px;
  background: var(--aqua-btn);
  border: 1.5px solid var(--panel-border);
}

.mq-lines i:last-child {
  width: 32px;
  background: #f7c04a;
  border-color: var(--gold-edge);
}

.overlay-chain .stage-tag {
  position: absolute;
  right: 16px;
  top: 18px;
  padding: 2px 9px;
  border-radius: 3px;
  border: 1.5px solid var(--panel-border);
  background: var(--ice-card);
  color: var(--mint);
  font-size: 9.5px;
  letter-spacing: .5px;
  text-transform: uppercase;
  box-shadow: 0 2px 0 var(--panel-shadow);
}

.overlay-chain .stage-flow {
  position: absolute;
  right: 20px;
  top: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.stage-arrow {
  color: #ffe59a;
  font-size: 18px;
  font-weight: 900;
  text-shadow: 0 2px 0 var(--gold-edge);
}

.stage-net-badge {
  padding: 6px 11px;
  border-radius: 4px;
  border: 2px solid var(--gold-edge);
  background: var(--mint-btn);
  color: var(--gold-ink);
  font-size: 12.5px;
  box-shadow: 0 3px 0 var(--panel-shadow);
}

.overlay-hide .stage-tap-ring {
  position: absolute;
  right: 48px;
  top: 28px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 2px solid var(--gold-edge);
  background: var(--mint-btn);
  color: var(--gold-ink);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--panel-shadow);
}

.howto-copy {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 8px;
  z-index: 2;
  pointer-events: none;
  padding: 7px 22px 7px 11px;
  background: radial-gradient(ellipse at 50% 45%, #fcf2dc 0%, #efd6ac 75%, #dec08e 100%);
  border: 1.5px solid #7d5b34;
  border-radius: 2px;
  text-align: left;
  box-shadow: 0 2px 0 #664825, 0 5px 12px rgba(2, 16, 18, .52);
}

.howto-copy::after {
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 14px;
  height: 14px;
  background: linear-gradient(225deg, #072729 46%, #7d5b34 49%, #f8ebd0 76%, #d2b17f 100%);
  box-shadow: -1.5px 1.5px 3px rgba(58, 34, 12, .28);
}

.howto-copy b {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  color: #452812;
  line-height: 1.32;
}

.howto-warn {
  bottom: 10px;
  padding: 8px 22px 8px 12px;
  background: radial-gradient(ellipse at 50% 45%, #fff3c7 0%, #f7d682 78%, #e5b754 100%);
  border-color: #6a3c06;
  text-align: center;
}

.howto-copy.howto-warn b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 14.5px;
  color: #4a1c00;
  letter-spacing: .3px;
}

.howto-copy span {
  display: block;
  font-size: 11.5px;
  line-height: 1.32;
  color: #d6f7de;
  font-weight: 600;
}

.howto-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #082e2f;
  border-top: 2px solid var(--panel-border);
}

.help-box .howto-arrow {
  width: 30px;
  height: 28px;
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--ink);
  text-shadow: none;
}

.help-box .howto-arrow::before,
.help-box .howto-arrow::after {
  clip-path: var(--poly-sq);
}

.help-box .howto-arrow::before {
  background: var(--panel-border);
}

.help-box .howto-arrow::after {
  inset: 2px;
  background: var(--aqua-btn-soft);
}

.help-box .howto-arrow svg {
  width: 15px;
  height: 15px;
}

.howto-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-box .howto-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  margin: 0;
  border-radius: 3px;
  background: #1c6661;
  border: 1.5px solid #041e20;
  filter: none;
  transition: width .18s, background .18s;
}

.help-box .howto-dot::before,
.help-box .howto-dot::after {
  display: none;
}

.help-box .howto-dot[aria-selected=true] {
  width: 24px;
  background: #f7c04a;
  border-color: var(--gold-edge);
}

.howto-count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.pedia-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.pedia-badge {
  padding: 3px 10px;
  border-radius: 3px;
  border: 2px solid var(--gold-edge);
  background: var(--mint-btn);
  color: var(--gold-ink);
  font-size: 10.5px;
  letter-spacing: .4px;
  box-shadow: 0 2px 0 var(--panel-shadow);
  flex-shrink: 0;
}

.pedia-badge.warn {
  border-color: #5c1b06;
  background: linear-gradient(180deg, #ffb997, #e55b38);
  color: #3a0b00;
}

#pedia .paper-sheet h2 {
  margin-bottom: 10px;
}

.pedia-screen {
  margin-bottom: 10px;
}

.pedia-stage {
  position: relative;
  background: #082e2f;
  touch-action: pan-y;
}

#pedia-canvas {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
}

.help-box .pedia-dots {
  gap: 5px;
}

.help-box .pedia-dots .howto-dot {
  width: 8px;
  height: 8px;
}

.help-box .pedia-dots .howto-dot[aria-selected=true] {
  width: 18px;
}

.help-box .pedia-desc {
  min-height: 44px;
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.48;
  color: #472a14;
  font-weight: 700;
}

.dur {
  margin: 0 0 14px;
}

.dur-label {
  display: block;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #633e1e;
  margin-bottom: 7px;
  font-weight: 800;
}

.dur-opts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.help-box .dur-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 8px;
  color: #4a2b13;
  text-shadow: none;
  font-size: 20px;
  font-weight: 650;
  line-height: 1;
}

.help-box .dur-opt:nth-child(even)::before,
.help-box .dur-opt:nth-child(even)::after {
  clip-path: var(--poly-b);
}

.help-box .dur-opt::after {
  background: linear-gradient(180deg, #f5e4c2, #e0c18f);
}

.help-box .dur-opt small {
  font-size: 9px;
  letter-spacing: .8px;
  font-weight: 800;
  color: #754e2b;
  text-transform: uppercase;
}

.help-box .dur-opt:hover::after {
  filter: brightness(1.08);
}

.help-box .dur-opt[aria-checked=true] {
  color: var(--gold-ink);
  text-shadow: 0 1px 0 rgba(255, 244, 210, .6);
}

.help-box .dur-opt[aria-checked=true]::after {
  background: var(--mint-btn);
}

.help-box .dur-opt[aria-checked=true] small {
  color: #5a3307;
}

/* Bingkai cokelat-emas untuk tombol utama & pilihan aktif */
.help-box button::before,
.reload::before {
  background: var(--gold-edge);
}

.help-box .ghost::before,
.help-box .dur-opt::before,
.help-box .menu-mute::before {
  background: #87633b;
}

.help-box .ghost::before {
  background: var(--panel-border);
}

.help-box .dur-opt[aria-checked=true]::before,
.motion[aria-pressed=true]::before,
.follow[aria-pressed=true]::before,
.icon-button[aria-pressed=true]::before {
  background: var(--gold-edge);
}

.help-box .dur-opt+.dur-opt {
  margin-top: 0;
}

.dur-custom {
  margin-top: 8px;
}

.menu-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.menu-secondary button+button,
.menu-secondary > button {
  margin-top: 0;
}

.res-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 6px 0 14px;
}

.res-card.res-catch {
  position: relative;
  border: 2.5px solid var(--panel-border);
  border-radius: 6px;
  padding: 16px 14px 14px;
  background:
    radial-gradient(circle at 50% 18%, rgba(164, 255, 226, .18), transparent 62%),
    var(--ice-panel);
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .34), 0 4px 0 var(--panel-shadow), 0 10px 22px rgba(3, 22, 24, .25);
  text-align: center;
}

.res-grid b.res-catch-num {
  display: block;
  font-size: clamp(46px, 9vw, 56px);
  font-weight: 400;
  line-height: 1.02;
  color: #fff8d4;
  text-shadow: 0 3px 0 #052627, 0 8px 18px rgba(4, 24, 26, .45);
}

.res-of {
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 700;
  color: #9de8c4;
  text-shadow: 0 2px 0 #052627;
}

.res-card.res-catch small {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: #d6f9e2;
  font-weight: 800;
  text-transform: uppercase;
  margin-top: 6px;
}

.res-card.res-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 2px solid #9d7232;
  border-radius: 5px;
  padding: 9px 14px;
  background: linear-gradient(180deg, #fff2c6 0%, #f1d084 100%);
  box-shadow: inset 0 1.5px 0 rgba(255, 253, 236, .85), 0 3px 0 #704b19;
  text-align: left;
}

.res-card.res-record.is-new {
  border-color: var(--gold-edge);
  background: var(--mint-btn);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 240, .85), 0 3px 0 #5b3204;
}

.res-record-info {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.res-trophy {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1.5px 0 rgba(90, 48, 4, .35));
}

.res-card.res-record small {
  display: block;
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .9px;
  color: #6b4111;
  font-weight: 800;
  text-transform: uppercase;
}

.res-new-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #4e2602;
  color: #ffe99c;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
}

.res-card.res-record b {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  color: #4a2403;
  text-shadow: 0 1.5px 0 rgba(255, 250, 230, .75);
  flex-shrink: 0;
}

.res-record-unit {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 800;
  color: #6b4111;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.res-duel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 14px;
}

.duel-card {
  border: 2px solid #8c683f;
  border-radius: 5px;
  padding: 12px;
  background: linear-gradient(180deg, #fcf2dc, #ebd1a4);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .65), 0 4px 0 #70512e;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.duel-card.winner {
  border-color: #8f5306;
  background: linear-gradient(160deg, #fff6c8 0%, #ffe085 100%);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .75), 0 4px 0 #663802;
}

.duel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.duel-name {
  font-weight: 800;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.duel-card.left .duel-name {
  color: #0b5b66;
}

.duel-card.right .duel-name {
  color: #943c08;
}

.duel-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .8px;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1.5px solid #6b3b02;
  background: linear-gradient(180deg, #ffda66, #ee9418);
  color: #3d1b00;
  text-transform: uppercase;
  flex-shrink: 0;
}

.duel-score {
  font-size: 32px;
  line-height: 1.05;
  color: #452812;
}

.duel-score small {
  font-size: 10px;
  letter-spacing: 1px;
  color: #704926;
  font-weight: 800;
  text-transform: uppercase;
  margin-left: 4px;
  font-family: var(--font-body);
}

.duel-meta {
  font-size: 11px;
  color: #5c391c;
  font-weight: 700;
  line-height: 1.35;
}

/* ===== Quiz Popover ===== */
.quiz {
  position: fixed;
  z-index: 5;
  left: 0;
  top: 0;
  width: min(326px, calc(100vw - 36px));
  padding: 15px 15px 14px;
  border: 2.5px solid var(--panel-border);
  border-radius: 6px;
  background: var(--ice-panel);
  color: var(--ink);
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .34), 0 5px 0 var(--panel-shadow), 0 14px 32px #031a1c77;
  transform: translate(-50%, -100%);
  animation: quizin .15s ease-out;
}

.quiz-timer {
  position: absolute;
  top: -27px;
  left: -19px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2.5px solid var(--panel-border);
  background: radial-gradient(circle at 35% 30%, #247b74, #0f4443);
  box-shadow: inset 0 2px 0 rgba(205, 248, 224, .35), 0 4px 0 var(--panel-shadow);
  color: #f4ffec;
  font-size: 31px;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  transition: color .18s, transform .18s;
}

.quiz-timer svg {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  transform: rotate(-90deg);
}

.quiz-timer circle {
  fill: none;
  stroke-width: 4.5;
}

.quiz-timer .qt-track {
  stroke: #ffffff26;
}

.quiz-timer .qt-ring {
  stroke: #b9f29e;
  stroke-linecap: round;
  stroke-dasharray: 150.8;
  stroke-dashoffset: 0;
  transition: stroke .18s;
}

.quiz-timer span {
  position: relative;
  text-shadow: 0 1.5px 0 #052526;
  transform: translateY(-1px);
}

.quiz-timer.warn {
  background: radial-gradient(circle at 35% 30%, #8f5c0d, #573404);
  border-color: #3d2402;
  color: #ffea9f;
}

.quiz-timer.warn .qt-ring {
  stroke: #ffd23f;
}

.quiz-timer.urgent {
  background: radial-gradient(circle at 35% 30%, #b32f25, #70160f);
  border-color: #470a06;
  color: #ffffff;
  box-shadow: 0 4px 0 #380704, 0 8px 20px #5e110b77;
  animation: qtpulse .36s ease-in-out infinite alternate;
}

.quiz-timer.urgent span {
  text-shadow: 0 1.5px 0 #4d0d08;
}

.quiz-timer.urgent .qt-ring {
  stroke: #ff9f8e;
}

@keyframes qtpulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.11);
  }
}

.quiz::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--tx, 0px));
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: #0f4443;
  border-right: 2.5px solid var(--panel-border);
  border-bottom: 2.5px solid var(--panel-border);
  transform: translateX(-50%) rotate(45deg);
}

.quiz.below {
  transform: translate(-50%, 0);
}

.quiz.below::after {
  bottom: auto;
  top: -8px;
  background: #1a6661;
  transform: translateX(-50%) rotate(225deg);
}

@keyframes quizin {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-left: 38px;
  min-height: 32px;
  margin-bottom: 11px;
}

.quiz-q {
  font-size: 15.5px;
  font-weight: 800;
  color: #f4ffec;
  text-shadow: 0 1px 0 #062b2d;
  text-align: left;
  line-height: 1.25;
  flex: 1;
}

.quiz-close {
  width: 32px;
  height: 32px;
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  background: var(--ice-card);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--panel-shadow);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
}

.quiz-close:hover {
  filter: brightness(1.06);
}

.quiz-close svg {
  width: 16px;
  height: 16px;
}

.quiz-opts {
  display: grid;
  gap: 8px;
}

.quiz-opts button {
  position: relative;
  z-index: 0;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 4px;
  padding: 11px 14px;
  background: transparent;
  color: #ffffff;
  text-shadow: 0 1.5px 0 #062b2d;
  font-size: 15.5px;
  font-weight: 800;
  text-align: left;
  min-height: 48px;
  filter: drop-shadow(0 3px 0 var(--panel-shadow));
  transition: transform .08s;
}

.quiz-opts button::before,
.quiz-opts button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: var(--poly-a);
  background: var(--panel-border);
}

.quiz-opts button:nth-child(even)::before,
.quiz-opts button:nth-child(even)::after {
  clip-path: var(--poly-b);
}

.quiz-opts button::after {
  inset: 2px;
  z-index: -1;
  background: var(--aqua-btn);
}

.quiz-opts button:active:not(:disabled) {
  transform: translateY(2px);
}

.quiz-opts button i {
  font-style: normal;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 3px;
  background: #063d5c66;
  border: 1.5px solid #ffffff55;
  font-size: 12.5px;
  color: #ffffff;
  text-shadow: none;
  flex-shrink: 0;
}

.quiz-opts button:hover:not(:disabled)::after {
  filter: brightness(1.07);
}

.quiz-opts button.ok {
  color: #ffffff;
  text-shadow: 0 1.5px 0 #0b522a;
}

.quiz-opts button.ok::before {
  background: #0b522a;
}

.quiz-opts button.ok::after {
  background: linear-gradient(180deg, #43d37e, #24a459);
}

.quiz-opts button.bad {
  color: #ffffff;
  text-shadow: 0 1.5px 0 #6e160f;
}

.quiz-opts button.bad::before {
  background: #6e160f;
}

.quiz-opts button.bad::after {
  background: linear-gradient(180deg, #f57367, #d14539);
}

.quiz-opts button:disabled:not(.ok):not(.bad) {
  opacity: .56;
}

/* ===== Forms & Challenge Dialog ===== */
.game-field {
  display: block;
  margin: 10px 0 5px;
  color: #59361a;
  font-weight: 800;
  font-size: 12.5px;
}

.game-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 2px solid #967247;
  border-radius: 4px;
  background: #fff9ec;
  color: #3d220d;
  box-shadow: inset 0 2px 4px rgba(90, 58, 28, .15);
}

.game-input::placeholder {
  color: #9c7b55;
}

.player-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#duration,
#challenge-duration {
  width: 10em;
}

.challenge-dialog {
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: inherit;
  max-width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}

.challenge-dialog::backdrop {
  background: #05272bd4;
  backdrop-filter: blur(6px);
}

.challenge-dialog .help-box {
  width: 100%;
}

.challenge-dialog button {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.game-field.player-left {
  color: #0b5d69;
}

.game-field.player-right {
  color: #9e4108;
}

#handoff {
  background: #0b2d31a6;
}

/* ===== Responsive Breakpoints ===== */
@media (max-width: 1080px) {
  .topbar {
    left: 20px;
    right: 20px;
  }

  .brand,
  .actions {
    min-width: 120px;
  }

  .habitat {
    padding: 10px 16px;
  }

  .dock {
    gap: 13px;
    padding: 14px;
    width: calc(100% - 40px);
  }

  .species {
    flex-basis: 124px;
    padding: 6px 4px;
    gap: 0;
  }

  .species canvas {
    width: 47px;
    height: 31px;
  }

  .species span {
    font-size: 10px;
  }

  .follow {
    width: 48px;
  }

  .scene-title {
    left: 30px;
  }

  .guide {
    right: 29px;
  }
}

@media (max-width: 960px) {
  body[data-mode=play] .brand {
    min-width: 0;
  }

  body[data-mode=play] .brand-text {
    display: none;
  }

  body[data-mode=play] .actions {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    left: 16px;
    right: 16px;
    top: max(14px, env(safe-area-inset-top));
    flex-wrap: wrap;
    gap: 12px;
  }

  body[data-mode=play] .topbar {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .brand,
  .actions {
    min-width: 0;
  }

  .brand-name {
    font-size: 22px;
  }

  .brand-icon {
    height: 36px;
    width: 36px;
    border-radius: 11px;
  }

  .brand-icon svg {
    height: 22px;
    width: 22px;
  }

  .brand-sub {
    font-size: 8px;
    letter-spacing: 2px;
  }

  .actions {
    gap: 6px;
  }

  .icon-button {
    height: 35px;
    width: 35px;
  }

  .icon-button svg {
    height: 17px;
    width: 17px;
  }

  .habitats {
    order: 3;
    width: 100%;
    padding: 4px;
    justify-content: space-between;
  }

  .habitat {
    flex: 1;
    justify-content: center;
    padding: 10px 6px;
    font-size: 11px;
  }

  .scene-title {
    top: 150px;
    left: 25px;
  }

  .scene-title h1 {
    font-size: 38px;
    margin-top: 10px;
  }

  .scene-title h1 small {
    font-size: 9px;
    margin-left: 10px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 2px;
  }

  .scene-title p {
    font-size: 12px;
  }

  .guide {
    display: none;
  }

  .dock {
    bottom: 85px;
    width: calc(100% - 28px);
    padding: 13px;
    gap: 12px;
    display: grid;
    grid-template-columns: 1fr 46px;
    border-radius: 5px;
  }

  .species-group {
    grid-column: 1 / 3;
  }

  .species-heading {
    gap: 8px;
  }

  .species-heading .group-label {
    line-height: 1.5;
  }

  .species-paging button {
    width: 30px;
    height: 30px;
  }

  .group-label {
    font-size: 8px;
    margin-bottom: 7px;
  }

  .group-label small {
    font-size: 8px;
  }

  .species-list {
    padding-bottom: 5px;
  }

  .species {
    flex-basis: 116px;
    min-height: 40px;
    padding: 4px 5px;
    border-radius: 4px;
    gap: 3px;
    justify-content: center;
  }

  .species canvas {
    width: 43px;
    height: 29px;
  }

  .species span {
    font-size: 10px;
  }

  .divider {
    display: none;
  }

  .motions {
    gap: 4px;
  }

  .motion {
    padding: 7px 2px;
    gap: 4px;
    border-radius: 4px;
    font-size: 9px;
  }

  .motion svg {
    height: 15px;
    width: 15px;
  }

  .follow {
    width: 46px;
    height: 47px;
    margin-top: 17px;
    font-size: 8px;
    border-radius: 4px;
  }

  .follow svg {
    height: 16px;
    width: 16px;
  }

  .journey {
    width: calc(100% - 52px);
  }

  .journey-labels {
    font-size: 8px;
  }

  .toast {
    top: 126px;
    font-size: 11px;
  }

  .paused {
    top: 154px;
    right: 22px;
    font-size: 8px;
  }

  .tag {
    font-size: 10px;
    padding: 5px 9px;
  }

  .hud {
    top: max(56px, calc(env(safe-area-inset-top) + 46px));
  }

  .hud-stats {
    gap: 6px;
  }

  .hud-box,
  .hud-timebox {
    min-width: 132px;
    padding: 8px 20px 8px;
    border-radius: 5px;
  }

  .hud-box b,
  .hud-time {
    font-size: 34px !important;
  }

  .hud-box small {
    font-size: 10px;
    margin-top: 4px;
  }

  .hud-chain {
    gap: 10px;
    padding: 7px 21px 7px 11px;
    clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 0 100%);
  }

  .hud-chain::after {
    width: 13px;
    height: 13px;
  }

  .hud-chain canvas {
    width: 56px;
    height: 30px;
  }

  .hud-chain small {
    font-size: 9.5px;
  }

  .hud-chain b {
    font-size: 15px;
  }

  .monitor-alert {
    padding: 6px 12px 6px 8px;
  }

  .monitor-alert-text b {
    font-size: 12px;
  }

  .monitor-alert-text small {
    font-size: 10px;
  }
}

@media (max-width: 440px) {

  .player-pair,
  .res-duel,
  .menu-secondary {
    grid-template-columns: 1fr;
  }

  .help-box {
    padding: 9px;
  }

  .paper-sheet {
    padding: 13px 13px 12px;
  }

  .help-box .dur-opt {
    font-size: 18px;
    padding: 8px 2px 7px;
  }
}

@media (max-height: 560px) {
  .topbar {
    top: max(10px, env(safe-area-inset-top));
    left: 16px;
    right: 16px;
    flex-wrap: nowrap;
  }

  .habitats {
    width: auto;
    order: initial;
    padding: 3px;
  }

  .habitat {
    padding: 8px 14px;
    font-size: 10px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 20px;
  }

  .brand-sub {
    font-size: 7px;
  }

  .icon-button {
    height: 33px;
    width: 33px;
  }

  .scene-title {
    top: 79px;
    left: 24px;
  }

  .scene-title h1 {
    font-size: 29px;
    margin: 8px 0 5px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .scene-title p {
    font-size: 11px;
  }

  .guide {
    display: none;
  }

  .dock {
    bottom: 51px;
    width: calc(100% - 40px);
    padding: 9px 12px;
    display: flex;
    gap: 12px;
    border-radius: 5px;
  }

  .group-label {
    font-size: 7px;
    margin-bottom: 5px;
  }

  .group-label small {
    display: none;
  }

  .species-heading {
    margin-bottom: 1px;
  }

  .species-heading .group-label {
    line-height: 1.2;
  }

  .species-paging button {
    width: 24px;
    height: 24px;
  }

  .species-list {
    gap: 4px;
    padding-bottom: 4px;
  }

  .species {
    flex-basis: 110px;
    min-height: 34px;
    padding: 4px 3px;
    gap: 1px;
  }

  .species canvas {
    width: 40px;
    height: 24px;
  }

  .species span {
    font-size: 9px;
  }

  .motion {
    padding: 5px 2px;
    font-size: 8px;
    gap: 3px;
  }

  .motion svg {
    height: 13px;
    width: 13px;
  }

  .follow {
    margin-top: 10px;
    width: 40px;
    height: 39px;
    font-size: 7px;
  }

  .follow svg {
    height: 13px;
    width: 13px;
  }

  .journey {
    bottom: 10px;
    width: min(560px, calc(100% - 80px));
  }

  .journey-labels {
    font-size: 7px;
    margin-top: 2px;
  }

  .track,
  .track input {
    height: 18px;
  }

  .paused {
    top: 81px;
  }

  .toast {
    top: 62px;
    font-size: 10px;
  }

  .hud {
    top: max(10px, env(safe-area-inset-top));
  }

  .hud-box,
  .hud-timebox {
    padding: 6px 16px 7px;
    min-width: 118px;
  }

  .hud-box b,
  .hud-time {
    font-size: 28px !important;
  }

  .hud-box small {
    margin-top: 3px;
    font-size: 9px;
  }

  .hud-sub {
    margin-top: 6px;
  }

  .hud-chain {
    gap: 9px;
    padding: 5px 19px 6px 10px;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  }

  .hud-chain::after {
    width: 12px;
    height: 12px;
  }

  .hud-chain canvas {
    width: 48px;
    height: 26px;
  }

  .hud-chain small {
    font-size: 9px;
  }

  .hud-chain b {
    font-size: 14px;
  }

  .monitor-alert {
    margin-top: 4px;
    padding: 4px 10px;
  }

  .game-box {
    padding: 10px;
  }

  .paper-sheet {
    padding: 13px 13px 12px;
  }

  .game-box h2 {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .howto-screen {
    margin-bottom: 10px;
  }

  .howto-slide {
    height: 152px;
  }

  #pedia-canvas {
    height: 150px;
  }

  .help-box .pedia-desc {
    min-height: 36px;
    margin-bottom: 9px;
    font-size: 12.5px;
  }

  .howto-copy {
    left: 7px;
    right: 7px;
    bottom: 6px;
    padding: 5px 18px 5px 9px;
  }

  .howto-copy b {
    font-size: 11px;
  }

  .dur {
    margin-bottom: 10px;
  }

  .dur-label {
    margin-bottom: 4px;
  }

  .help-box .dur-opt {
    font-size: 16px;
    padding: 6px 4px;
  }

  .res-grid b.res-catch-num {
    font-size: 42px;
  }

  .res-card.res-record b {
    font-size: 24px;
  }

  .quiz {
    padding: 10px 12px;
  }

  .quiz-timer {
    width: 52px;
    height: 52px;
    top: -22px;
    left: -14px;
    font-size: 26px;
  }

  .quiz-head {
    padding-left: 32px;
    min-height: 28px;
  }

  .quiz-q {
    font-size: 14px;
  }

  .quiz-opts {
    gap: 6px;
  }

  .quiz-opts button {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 14px;
  }
}

@media (max-height: 560px) and (max-width: 560px) {
  .hud {
    top: max(48px, calc(env(safe-area-inset-top) + 42px));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  .loading-fill::after {
    animation: none;
  }

  .hud-time.low,
  .monitor-alert,
  .monitor-alert-icon,
  .quiz-timer.urgent,
  .hud-chain,
  .quiz,
  .howto-slide,
  .howto-slide[data-slide="3"].active,
  .pan-arrow svg,
  .pan-arrow .pa-drop {
    animation: none;
  }
}