:root {
  --page: #0c1014;
  --playfield: #10151a;
  --track: #141a20;
  --ink: #e8e8e3;
  --muted: #858c91;
  --line: #2e353b;
  --two: #69a7a2;
  --three: #b87390;
  --damage: #ce6155;
  --font: "Times New Roman", Times, serif;
  --page-gutter: clamp(32px, 6vw, 96px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
}

.orientation-message {
  display: none;
}

.game-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  padding-top: 22px;
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
  padding: 0 var(--page-gutter);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--two);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.025em;
}

h1 {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(34px, 4vw, 46px);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 0.95;
}

.piece-label {
  display: grid;
  gap: 4px;
  min-width: 250px;
  text-align: right;
}

#composer-label {
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px;
}

.piece-select {
  appearance: none;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  text-align: right;
  cursor: pointer;
}

.piece-select:focus-visible {
  outline: 1px solid var(--two);
  outline-offset: 4px;
}

.tempo-control {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.tempo-control input {
  width: 150px;
  height: 28px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.tempo-control input::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}

.tempo-control input::-webkit-slider-thumb {
  width: 10px;
  height: 18px;
  margin-top: -8px;
  appearance: none;
  border: 1px solid var(--two);
  border-radius: 0;
  background: var(--ink);
}

.tempo-control input::-moz-range-track {
  height: 2px;
  border: 0;
  background: var(--line);
}

.tempo-control input::-moz-range-thumb {
  width: 10px;
  height: 18px;
  border: 1px solid var(--two);
  border-radius: 0;
  background: var(--ink);
}

.tempo-control input:disabled {
  cursor: default;
  opacity: 0.35;
}

.tempo-control output {
  min-width: 3ch;
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  text-align: right;
}

.hud {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 4px;
}

#lives-value {
  display: flex;
  gap: 6px;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
}

.life-mark {
  color: var(--ink);
}

.life-mark.is-empty {
  color: var(--line);
}

.game-card {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  background: var(--playfield);
  touch-action: manipulation;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 0;
  min-height: 310px;
  flex: 1;
}

.start-instruction {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.start-instruction.is-ending {
  top: auto;
  bottom: 24px;
  transform: translateX(-50%);
}

.start-instruction[hidden] {
  display: none;
}

@media (max-width: 700px) {
  :root {
    --page-gutter: 20px;
  }

  .game-shell {
    padding-top: 16px;
  }

  .game-header {
    gap: 14px;
    margin-bottom: 11px;
  }

  h1 {
    font-size: 32px;
  }

  .piece-label {
    min-width: 0;
    max-width: 190px;
  }

  .piece-select {
    font-size: 16px;
  }

  .tempo-control input {
    width: 105px;
  }

  .game-canvas {
    min-height: 340px;
  }
}

@media (any-pointer: coarse) and (orientation: portrait) {
  .orientation-message {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: grid;
    margin: 0;
    padding: 24px;
    place-items: center;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font);
    font-size: 24px;
    font-weight: 700;
    text-align: center;
  }

  .game-shell {
    visibility: hidden;
    pointer-events: none;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  :root {
    --page-gutter: 20px;
  }

  .game-shell {
    padding-top: 10px;
  }

  .game-header {
    gap: 14px;
    margin-bottom: 8px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 11px;
  }

  h1 {
    font-size: 30px;
  }

  .piece-label {
    min-width: 0;
    gap: 2px;
  }

  #composer-label {
    font-size: 12px;
  }

  .piece-select {
    font-size: 16px;
  }

  .tempo-control {
    min-height: 22px;
  }

  .tempo-control input {
    width: 110px;
    height: 22px;
  }

  .hud {
    min-height: 20px;
    margin-top: 0;
  }

  #lives-value {
    font-size: 20px;
  }

  .game-canvas {
    min-height: 0;
  }
}
