:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Yu Gothic", Meiryo, sans-serif;
  color: #f1eee4;
  background: #101611;
  --ink: #f1eee4;
  --muted: #b8b7aa;
  --accent: #ee987b;
  --line: #e2dfc82e;
  --inset: clamp(1.25rem, 3.15vw, 3.75rem);
  --left: clamp(2rem, 7.2vw, 8.75rem);
  --mono: Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; }
button, input { font: inherit; }

button {
  border: 0;
  color: inherit;
  background: none;
  cursor: pointer;
}

button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #f9bd9e; outline-offset: 4px; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

kbd {
  display: inline-grid;
  min-width: 1.42rem;
  min-height: 1.37rem;
  padding: 0.11rem 0.28rem;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: inherit;
  font: 0.73rem/1.05 var(--mono);
  white-space: nowrap;
}

#view {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #101611;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(0deg, #090d0bf2, #090d0b48 13%, transparent 32%),
    radial-gradient(ellipse at 50% 43%, transparent 40%, #090b0a26 64%, #080a09ac 100%);
}

[data-screen="title"] .vignette,
[data-screen="pause"] .vignette,
[data-screen="clear"] .vignette,
[data-screen="error"] .vignette {
  background:
    linear-gradient(90deg, #0c0f0df5, #0c0f0dd9 25%, #0c0f0d50 54%, transparent 78%),
    linear-gradient(0deg, #080b09d6, transparent 22%),
    radial-gradient(ellipse at 60% 50%, transparent 34%, #080b0a8f);
}

[data-screen="catalog"] .vignette {
  background:
    linear-gradient(90deg, #080e0bf6, #0b120ec9 25%, transparent 52%),
    linear-gradient(0deg, #080b09d6, transparent 22%),
    radial-gradient(ellipse at 63% 42%, transparent 41%, #080b0a86);
}

[data-screen="catalog"].catalog-expanded .vignette {
  background: linear-gradient(0deg, #080b0abd, transparent 17%),
    radial-gradient(ellipse at 50% 45%, transparent 44%, #080b0a60);
}

.header {
  position: fixed;
  z-index: 2;
  inset: 1.45rem var(--inset) auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.73rem;
  color: #eae6d7;
  font: 600 0.76rem/1 var(--mono);
  letter-spacing: 0.20em;
  text-shadow: 0 1px 6px #000;
}

[data-screen="title"] .wordmark > span:last-child { display: none; }

.lift-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.19rem;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid #b5b4a27a;
  border-radius: 2px;
}

.lift-symbol i {
  width: 0.27rem;
  height: 0.64rem;
  border: 1px solid #c9ccb0;
}

.lift-symbol i:first-child { border-right: 0; }
.lift-symbol i:last-child { border-left: 0; }

.utility { display: flex; align-items: center; gap: 0.45rem; pointer-events: auto; }

.utility button {
  display: inline-flex;
  min-height: 2.25rem;
  gap: 0.48rem;
  align-items: center;
  padding: 0.35rem 0.62rem;
  border: 1px solid #dedac637;
  border-radius: 2px;
  background: #111712ab;
  color: #e9e6d9;
  font-size: 0.82rem;
}

.utility button:hover { border-color: #b3b4a7; background: #222a22; }
.utility kbd { color: #c9c6b6; border-color: #e2dfc84d; }

.sound-icon { display: inline-flex; align-items: center; gap: 2px; width: 14px; height: 14px; }
.sound-icon i { width: 2px; height: 6px; background: currentColor; }
.sound-icon i:nth-child(2) { height: 12px; }
.sound-icon i:nth-child(3) { height: 9px; }
.utility [aria-pressed="true"] .sound-icon { opacity: 0.56; }

.left-sheet {
  position: fixed;
  top: 50%;
  left: var(--left);
  max-width: calc(100% - var(--left) - 1.5rem);
  max-height: calc(100dvh - 7.5rem);
  overflow: auto;
  transform: translateY(-50%);
}

.title-sheet { width: min(42rem, 54vw); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  margin: 0 0 1rem;
  color: var(--accent);
  font-size: 0.91rem;
  font-weight: 700;
  letter-spacing: 0.20em;
}

.eyebrow::before {
  width: 1.56rem;
  height: 1px;
  background: currentColor;
  content: "";
}

.title-type, .menu-title {
  font-family: Bahnschrift, "Arial", sans-serif;
  font-weight: 800;
  letter-spacing: -0.052em;
  text-shadow: 0 5px 35px #080a0866;
}

.title-type {
  margin: 0;
  font-size: clamp(4.3rem, min(8.8vw, 16.1vh), 9.15rem);
  line-height: 0.81;
}

.tagline {
  margin: 1.55rem 0 1.26rem;
  color: #ddd9ca;
  font-size: clamp(1rem, 1.28vw, 1.26rem);
  font-weight: 500;
  letter-spacing: 0.085em;
}

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(18.5rem, 100%);
  min-inline-size: 0;
  gap: 0.3rem;
  margin: 0;
  padding: 0.24rem;
  border: 1px solid #d9dbc744;
  border-radius: 2px;
  background: #101713d6;
}

.mode-picker label { position: relative; cursor: pointer; }
.mode-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-picker span {
  display: block;
  padding: 0.39rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #c0c0b1;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 650;
}
.mode-picker label:hover span { color: var(--ink); }
.mode-picker input:checked + span { border-color: #e9a18464; background: #b47f5625; color: #f5c0a7; }
.mode-picker input:focus-visible + span { outline: 2px solid #f9bd9e; outline-offset: 2px; }
.mode-summary { margin: 0.42rem 0 0.94rem; color: #d5d4c4; font-size: 0.82rem; }

.primary {
  display: inline-flex;
  justify-content: space-between;
  gap: 1.15rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.68rem 1.01rem;
  border: 1px solid #efae96;
  border-radius: 2px;
  background: #d9886d;
  color: #1b130f;
  font-weight: 750;
}

.primary:hover { background: #efaa90; }
.primary kbd { color: #33221b; border-color: #37211679; }
.primary-wide { width: min(18.5rem, 100%); }
.title-sheet .primary { min-height: 3.42rem; font-family: var(--mono); letter-spacing: 0.15em; }
.title-sheet .primary kbd { letter-spacing: 0; }

.title-menu, .secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.48rem 1.35rem;
  align-items: center;
}

.title-menu { margin-top: 1.02rem; }

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.25rem;
  padding: 0.31rem 0.04rem;
  border-bottom: 1px solid #c8cab75e;
  color: #e0ddce;
  font-size: 0.94rem;
}

.text-button:hover { color: #ffb196; border-color: #ffb196; }

.screen-footer {
  position: fixed;
  inset: auto var(--inset) 1.35rem;
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  color: #cccebe;
  font-size: 0.79rem;
}

.screen-footer span + span::before { margin-right: 0.9rem; color: #979a87; content: "·"; }

.catalog-sheet {
  position: fixed;
  inset: 4.8rem var(--inset) 1.6rem;
  display: grid;
  grid-template-columns: min(28vw, 24rem) 1fr;
  gap: 1.25rem;
  pointer-events: none;
}

.catalog-panel, .catalog-preview {
  border: 1px solid #d7decb43;
  border-radius: 2px;
  background: linear-gradient(145deg, #18231ef5, #101713f3);
  box-shadow: 0 0.8rem 3.5rem #060a0866;
  pointer-events: auto;
}

.catalog-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.2rem;
}

.catalog-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 0.65rem; }
.catalog-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.4vw, 2.05rem); line-height: 1.2; }
.catalog-heading output { flex-shrink: 0; color: #f6ac90; font: 0.92rem var(--mono); }
.catalog-panel progress { flex-shrink: 0; width: 100%; height: 0.33rem; margin: 0.85rem 0 1rem; accent-color: #db967a; }
.catalog-panel progress::-webkit-progress-bar { border-radius: 5px; background: #2c3930; }
.catalog-panel progress::-webkit-progress-value { border-radius: 5px; background: #db967a; }

.catalog-entries {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 0.42rem;
  min-height: 0;
  margin: 0;
  padding: 0.16rem 0.25rem 0.35rem 0.08rem;
  list-style: none;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #556a5b #18231c;
}
.catalog-entries:focus-visible { outline-offset: 0; }

.catalog-card {
  display: flex;
  flex-direction: column;
  gap: 0.31rem;
  width: 100%;
  height: 100%;
  min-height: 3.38rem;
  padding: 0.49rem 0.55rem;
  border: 1px solid #b4c0a941;
  border-radius: 2px;
  background: #243029;
  text-align: left;
}

.catalog-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.32rem;
  color: #b5c2b2;
  font: 0.73rem/1 var(--mono);
  letter-spacing: 0.055em;
}
.catalog-hard { color: #dfaa92; font: 0.68rem/1 "Segoe UI", "Yu Gothic", sans-serif; letter-spacing: 0; }
.catalog-card-name { color: #f2efdf; font-size: 0.86rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.catalog-card:disabled { border-color: #93a79529; background: #152019; }
.catalog-card:disabled .catalog-card-name { color: #aeb9aa; font-weight: 400; }
.catalog-card:hover:not(:disabled) { border-color: #f4aa8e; }
.catalog-card[aria-pressed="true"] { border-color: #e6997d; background: #44332a; }
.catalog-card[aria-pressed="true"] .catalog-card-meta { color: #efb7a0; }
.catalog-card:focus-visible { outline-offset: -3px; }
.catalog-panel > .text-button { align-self: start; flex-shrink: 0; margin-top: auto; }

.catalog-preview {
  align-self: end;
  justify-self: end;
  width: min(100%, 29rem);
  padding: 0.78rem 1.1rem 0.86rem;
}
.catalog-preview h3 { margin: 0.32rem 0 0; font-size: 1.28rem; line-height: 1.2; }
.catalog-preview p { margin: 0.45rem 0 0; color: #dbded0; font-size: 0.89rem; line-height: 1.45; }
#catalog-empty, #catalog-category { margin: 0; }
#catalog-category { color: #edab90; font-size: 0.75rem; letter-spacing: 0.06em; }
.catalog-controls { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.68rem; }
.catalog-controls button {
  min-width: 3.8rem;
  padding: 0.34rem 0.61rem;
  border: 1px solid #b4c0a963;
  border-radius: 2px;
  color: #dfded0;
  font-size: 0.84rem;
}
.catalog-controls button:hover { border-color: #f4aa8e; }
.catalog-controls button[aria-pressed="true"] { border-color: #e6997d; background: #44332a; color: #ffccb6; }
.catalog-filters { flex-shrink: 0; margin: 0 0 0.65rem; }
#catalog-no-results { margin: 0.5rem 0; color: var(--muted); font-size: 0.87rem; }
.catalog-preview .catalog-view-hint { color: var(--muted); font-size: 0.76rem; }
.catalog-preview-footer { display: flex; align-items: baseline; gap: 0.65rem; margin-top: 0.6rem; }
.catalog-preview-footer p { flex: 1; margin: 0; }
.catalog-preview-footer button { flex-shrink: 0; font-size: 0.79rem; }

.catalog-sheet.is-expanded { grid-template-columns: minmax(0, 1fr); inset-block-end: 0.9rem; }
.is-expanded .catalog-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.8rem;
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  padding: 0.52rem 0.7rem;
}
.is-expanded .catalog-preview :is(h3, #catalog-category, #catalog-empty, .catalog-view-hint) { display: none; }
.is-expanded .catalog-preview :is(.catalog-controls, .catalog-preview-footer) { margin-top: 0; }

.tutorial-sheet {
  position: fixed;
  inset: auto var(--inset) 2.66rem;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1.5rem;
  padding: 0.68rem 1.05rem 0.76rem;
  border: 1px solid #d9dbc744;
  border-left: 2px solid #d9886d;
  background: linear-gradient(90deg, #141b17f5, #171d19d9);
}

.tutorial-sheet .eyebrow { margin-bottom: 0.32rem; font-size: 0.81rem; line-height: 1.15; }
.tutorial-sheet .eyebrow::before { display: none; }
.tutorial-copy h2 { margin: 0 0 0.37rem; font-size: clamp(1.2rem, 1.75vw, 1.6rem); font-weight: 650; line-height: 1.22; }
.tutorial-copy p:last-child { margin: 0; color: #cbcec0; font-size: 0.88rem; line-height: 1.47; }
.tutorial-copy strong { color: var(--ink); font-weight: 650; }
.tutorial-sheet .primary { flex-shrink: 0; white-space: nowrap; }

.play-controls {
  position: fixed;
  inset: auto 0 3.05rem;
  text-align: center;
  pointer-events: none;
}

.choices { display: flex; justify-content: center; gap: 0.6rem; }

.choice {
  display: inline-flex;
  align-items: center;
  min-width: 9.7rem;
  gap: 0.63rem;
  padding: 0.55rem 0.76rem;
  border: 1px solid #dbd9c66e;
  border-radius: 2px;
  background: #151b16da;
  color: #faf4e6;
  text-align: left;
  font-size: 0.93rem;
  font-weight: 650;
  pointer-events: auto;
}

.choice kbd { min-width: 1.95rem; min-height: 1.95rem; color: #ef9c80; font-size: 1.2rem; }
.choice small { display: block; margin-top: 0.12rem; color: #beb9aa; font-size: 0.77rem; font-weight: 500; }
.choice:hover:not(:disabled) { border-color: #e69a7d; background: #343027; }
.choice:disabled { opacity: 0.46; }
.choice.is-selected { opacity: 0.85; border-color: #cb8a70; }
.movement-status { min-height: 1.3rem; margin: 0 0 0.35rem; color: #e9dfcf; font-size: 0.86rem; text-shadow: 0 2px 4px #000; }
.movement-status.fault { color: #ffad94; }

.look-help {
  position: fixed;
  inset: auto var(--inset) 1.08rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.90rem;
  color: #d1d2c4;
  font-size: 0.81rem;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.look-help kbd { margin-right: 0.14rem; border-color: #ccc9b284; }

.menu-sheet { width: min(30rem, 53vw); }
.menu-title { margin: 0; font-size: clamp(3.3rem, 6.5vw, 6.2rem); line-height: 0.89; }
.menu-subtitle { margin: 0.65rem 0 1.75rem; color: #dfdfd0; font-size: 1.06rem; letter-spacing: 0.12em; }
.menu-actions .secondary-actions { margin-top: 0.7rem; }
.menu-actions { margin-bottom: 1.65rem; }
.volume-row { display: flex; align-items: center; width: min(23rem, 100%); gap: 0.75rem; color: #deded0; font-size: 0.93rem; }
.volume-row + .volume-row { margin-top: 0.52rem; }
.volume-row > span { flex: 0 0 4.4rem; }
.volume-row input { flex: 1; min-width: 4rem; accent-color: #ed9b79; cursor: pointer; }
.volume-row output { min-width: 3.26rem; font: 0.87rem var(--mono); text-align: right; }

.clear-sheet .eyebrow { color: #cae3a6; }
.result-time { display: flex; flex-wrap: wrap; gap: 0.55rem 1rem; align-items: end; margin: 1.1rem 0; }
.result-time span { display: block; color: var(--muted); font-size: 0.85rem; }
.result-time strong { display: block; margin-top: 0.22rem; color: #f1f0e6; font: 600 clamp(1.9rem, 4.5vw, 3.5rem)/1.05 var(--mono); }
#new-best { margin: 0 0 0.22rem; color: #c4e09f; font-size: 0.88rem; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1.1rem; margin: 0 0 1.4rem; }
.metrics > div { padding-top: 0.5rem; border-top: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: 0.82rem; }
.metrics dd { margin: 0.24rem 0 0; font: 600 1.27rem/1.1 var(--mono); }
.clear-actions .primary { min-width: 8.1rem; justify-content: center; }

.details {
  width: min(32rem, calc(100% - 3rem));
  max-height: calc(100dvh - 4rem);
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid #ccc9b57a;
  border-radius: 3px;
  background: #1b241e;
  color: var(--ink);
  box-shadow: 0 14px 80px #050805c8;
}

.details::backdrop { background: #060906b8; }
.details h2 { margin: 0 0 0.95rem; font-size: 1.75rem; font-weight: 650; }
.details p { color: #e0e3d3; line-height: 1.7; }
.key-list { margin: 1.25rem 0; }
.key-list div { display: grid; grid-template-columns: 6.2rem 1fr; gap: 0.5rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.key-list dt { color: #efac91; font-size: 0.91rem; }
.key-list dd { margin: 0; font-size: 0.91rem; }
.record-list div { grid-template-columns: 1fr auto; }
.record-list dd { font-family: var(--mono); }
.record-table { width: 100%; border-collapse: collapse; }
.record-table th, .record-table td { padding: 0.62rem 0.48rem; border-bottom: 1px solid var(--line); text-align: right; }
.record-table th:first-child { padding-left: 0; text-align: left; }
.record-table th { color: #eab697; font-size: 0.86rem; font-weight: 650; }
.record-table td { color: #eeefde; font: 0.91rem var(--mono); }
.mute-row { display: block; margin: 1rem 0; color: #e3e4d8; }
.mute-row input { accent-color: #ed9b79; }
.dialog-close { margin-top: 0.25rem; }
.dialog-close kbd { border-color: #aea8946f; }

#webgl-error h1 { font-size: clamp(1.5rem, 2.7vw, 2.4rem); }
#webgl-error p { line-height: 1.7; }
.boot-message { position: fixed; inset: 50% 1rem auto; margin: 0; text-align: center; color: var(--muted); }
.boot-message p { margin: 0 0 0.7rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-height: 660px) {
  .title-sheet .eyebrow { margin-bottom: 0.65rem; }
  .tagline { margin-block: 1.05rem 0.85rem; }
  .mode-summary { margin-bottom: 0.65rem; }
  .header { top: 0.85rem; }
  .screen-footer { bottom: 0.75rem; }
  .menu-sheet .menu-subtitle { margin-bottom: 1.15rem; }
}
