:root {
  color-scheme: dark;
  --ivory: #ddd2bd;
  --cyan: #74cfc7;
  --orange: #cf7650;
  --steel: #17191f;
  --gold: #bda978;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #09090d;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 420px;
  overflow: hidden;
  background: #09090d;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

.hud {
  position: absolute;
  z-index: 5;
  inset: 20px 24px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ivory);
  pointer-events: none;
  transition: .3s;
}

.hud.hidden-ui { opacity: 0; }

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sigil {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(221, 210, 189, .28);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 12px;
  color: var(--orange);
  box-shadow: inset 0 0 18px rgba(207, 118, 80, .12);
}

.hud-brand div, .objective { display: grid; gap: 4px; }
.hud-brand small, .objective small { font-size: 8px; letter-spacing: .24em; color: #8e8a82; }
.hud-brand strong, .objective strong { font-size: 10px; letter-spacing: .18em; }

.objective {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.hud-actions {
  pointer-events: auto;
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(221, 210, 189, .18);
  border-radius: 50%;
  color: var(--ivory);
  background: rgba(12, 12, 16, .72);
}

.icon-button:hover { border-color: var(--orange); }

.node-hud {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.node-card {
  width: 78px;
  padding: 7px 8px 6px;
  border: 1px solid rgba(221, 210, 189, .16);
  background: rgba(12, 13, 17, .88);
  text-align: center;
}

.node-card.active {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(116, 207, 199, .12);
}

.node-card small {
  display: block;
  color: #969189;
  font-size: 8px;
  letter-spacing: .16em;
}

.node-card strong {
  display: block;
  margin: 3px 0 5px;
  color: var(--ivory);
  font-size: 11px;
}

.node-bar {
  height: 3px;
  background: #34343a;
  overflow: hidden;
}

.node-bar i {
  display: block;
  height: 100%;
  background: var(--cyan);
  transition: width .12s;
}

.controls-panel {
  position: absolute;
  z-index: 5;
  right: 24px;
  bottom: 20px;
  display: none;
  gap: 9px;
  color: #aaa49a;
  font-size: 8px;
  letter-spacing: .12em;
}

.controls-panel div {
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  min-width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(221, 210, 189, .24);
  border-radius: 3px;
  background: #15151a;
  color: var(--ivory);
  font-size: 8px;
  box-shadow: 0 2px 0 #09090b;
}

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 55%, rgba(31, 28, 35, .72), rgba(6, 6, 9, .96));
  opacity: 0;
  visibility: hidden;
  transition: .25s;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.menu-card {
  width: min(680px, calc(100% - 32px));
  text-align: center;
  color: var(--ivory);
}

.eyebrow {
  color: var(--orange);
  font-size: 9px;
  letter-spacing: .38em;
}

.menu-card h1 {
  margin: 14px 0 12px;
  font: 700 clamp(48px, 7vw, 88px) /.82 Georgia, serif;
  letter-spacing: -.055em;
  text-shadow: 0 12px 40px rgba(0, 0, 0, .7);
}

.menu-card h1 em {
  color: var(--orange);
  font-size: .45em;
  vertical-align: middle;
}

.subtitle {
  color: #aaa49a;
  font: italic 15px Georgia, serif;
}

.menu-view { margin: 34px auto 0; }

.primary-button {
  min-width: 280px;
  height: 52px;
  border: 1px solid #a9a08e;
  background: rgba(214, 198, 164, .07);
  color: var(--ivory);
  letter-spacing: .15em;
  font-size: 10px;
  box-shadow: inset 0 0 24px rgba(221, 210, 189, .03);
}

.primary-button:hover {
  background: rgba(207, 118, 80, .18);
  border-color: var(--orange);
}

.menu-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 18px;
}

.text-button, .back-button {
  border: 0;
  border-bottom: 1px solid rgba(221, 210, 189, .22);
  background: none;
  color: #aaa49a;
  padding: 8px 4px;
  letter-spacing: .18em;
  font-size: 9px;
}

.text-button:hover, .back-button:hover {
  color: var(--ivory);
  border-color: var(--orange);
}

.back-button { margin-top: 20px; }

.menu-card h2 {
  font: 700 24px Georgia, serif;
  letter-spacing: .08em;
}

.level-grid { display: grid; gap: 8px; }

.level-button {
  height: 82px;
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
  border: 1px solid rgba(221, 210, 189, .16);
  background: rgba(20, 20, 25, .72);
  color: var(--ivory);
  padding: 12px 18px;
}

.level-button:hover {
  border-color: var(--orange);
  transform: translateX(4px);
}

.level-button > span {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(221, 210, 189, .18);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--orange);
}

.level-button div { display: grid; gap: 7px; }
.level-button strong { font: 700 12px Georgia, serif; letter-spacing: .12em; }
.level-button small { color: #89867f; }

.instruction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}

.instruction-grid p {
  margin: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(221, 210, 189, .12);
  background: rgba(20, 20, 25, .55);
  padding: 12px;
}

.instruction-grid b { min-width: 54px; color: var(--cyan); }
.instruction-grid span { font-size: 11px; }

.tip {
  color: #aaa49a;
  font: italic 13px Georgia, serif;
}

.setting {
  max-width: 420px;
  min-height: 54px;
  margin: 8px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(221, 210, 189, .12);
  padding: 12px 16px;
  font-size: 10px;
  letter-spacing: .12em;
}

.setting input[type=range] {
  accent-color: var(--cyan);
  width: 180px;
}

#timerText {
  margin-top: 2px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
}

@media (min-width: 900px) {
  .controls-panel { display: flex; }
}

@media (max-width: 640px) {
  .hud { inset: 10px 12px auto; }
  .objective { display: none; }
  .node-hud { bottom: 10px; }
  .node-card { width: 64px; }
  .menu-card h1 { font-size: 46px; }
  .level-button { height: 68px; }
  .instruction-grid { grid-template-columns: 1fr; }
  .instruction-grid p { min-height: 48px; }
  .subtitle { padding: 0 20px; }
}

.countdown {
  position: absolute;
  z-index: 15;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  color: var(--ivory);
  font-size: 32px;
  font-weight: 700;
  text-shadow: 0 0 20px rgba(0, 0, 0, .8);
  pointer-events: none;
}

.countdown .digit {
  display: inline-block;
  line-height: 1;
}

.countdown .digit:nth-child(1) {
  animation: shake 1s infinite;
}

.countdown .digit:nth-child(2) {
  animation: shake 1s infinite 0.1s;
}

.countdown .digit:nth-child(3) {
  animation: shake 1s infinite 0.2s;
}

@keyframes shake {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
