@import url("https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;500;600;700&family=Silkscreen:wght@400;700&display=swap");

:root {
  color-scheme: dark;
  --ink: #16120d;
  --panel: #f6dfb4;
  --panel-dark: #a35f2a;
  --panel-deep: #4f2c1b;
  --cream: #fff4d0;
  --accent: #65d9ff;
  --teal: #058985;
  --shadow: rgba(15, 12, 9, 0.55);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Pixelify Sans", "Silkscreen", "Courier New", monospace;
  color: var(--cream);
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  font-smooth: never;
  touch-action: manipulation;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(7, 19, 20, 0.72), rgba(9, 17, 16, 0.36)),
    #0c1714;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.title-panel {
  position: absolute;
  top: clamp(14px, 3.4vh, 34px);
  left: 50%;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 32px));
  padding: 18px 18px 20px;
  text-align: center;
  pointer-events: auto;
  transition: opacity 180ms linear, transform 180ms linear;
}

.title-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
}

.kicker {
  margin: 0 0 12px;
  color: #f7d58b;
  font-family: "Pixelify Sans", "Silkscreen", "Courier New", monospace;
  font-size: clamp(12px, 1.4vw, 18px);
  text-shadow: 0 2px 0 #241405, 2px 0 0 #241405;
}

h1 {
  margin: 0 0 16px;
  color: #fff5c3;
  font-size: clamp(34px, 7.6vw, 92px);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow:
    0 5px 0 #8c3d20,
    5px 0 0 #8c3d20,
    5px 5px 0 #32160f,
    0 10px 18px rgba(0, 0, 0, 0.42);
}

button {
  appearance: none;
  border: 0;
  font: inherit;
  letter-spacing: 0;
  cursor: pointer;
}

.primary-action,
.continue {
  color: #1d130b;
  background: #ffe38d;
  border: 4px solid #3a1c12;
  box-shadow:
    inset 0 -5px 0 #d58e35,
    0 5px 0 #1b0d08,
    0 10px 18px rgba(0, 0, 0, 0.35);
}

.primary-action {
  min-width: 154px;
  padding: 12px 18px 16px;
  font-size: clamp(12px, 1.5vw, 17px);
}

.dialog {
  position: absolute;
  right: clamp(14px, 3vw, 42px);
  bottom: clamp(14px, 4vh, 38px);
  left: clamp(14px, 3vw, 42px);
  min-height: 164px;
  padding: 18px 18px 20px;
  color: var(--ink);
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
    var(--panel);
  border: 6px solid var(--panel-deep);
  outline: 4px solid #f9c756;
  box-shadow:
    inset 0 0 0 4px var(--panel-dark),
    0 14px 0 rgba(48, 23, 12, 0.45),
    0 18px 34px var(--shadow);
  transition: opacity 120ms linear;
}

.dialog.hidden {
  opacity: 0;
  pointer-events: none;
}

.speaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.speaker,
.chapter {
  display: block;
  color: #ffe7a2;
  background: #4d2618;
  border: 3px solid #1f0e08;
  box-shadow: inset 0 -3px 0 #8a4b25;
  padding: 8px 10px 10px;
  font-family: "Pixelify Sans", "Silkscreen", "Courier New", monospace;
  font-size: clamp(13px, 1.5vw, 18px);
  line-height: 1;
}

.chapter {
  color: #bfefff;
}

.dialog-text {
  min-height: 54px;
  margin: 0;
  max-width: 1100px;
  font-family: "Pixelify Sans", "Silkscreen", "Courier New", monospace;
  font-size: clamp(18px, 2.15vw, 27px);
  line-height: 1.22;
}

.continue {
  position: absolute;
  right: 18px;
  bottom: 16px;
  min-width: 152px;
  padding: 10px 14px 14px;
  font-size: clamp(11px, 1.2vw, 14px);
}

.continue:disabled {
  opacity: 0.62;
  cursor: default;
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 520px;
  }

  .title-panel {
    top: 10px;
  }

  .dialog {
    min-height: 194px;
    padding: 14px;
  }

  .speaker-row {
    margin-bottom: 10px;
  }

  .speaker,
  .chapter {
    padding: 7px 8px 9px;
    font-size: 12px;
  }

  .dialog-text {
    padding-right: 0;
    font-size: 16px;
    line-height: 1.25;
  }

  .continue {
    right: 14px;
    bottom: 12px;
    min-width: 132px;
  }
}

@media (pointer: coarse) and (max-height: 520px), (pointer: coarse) and (orientation: landscape) {
  .game-shell {
    height: 100dvh;
    min-height: 0;
  }

  .title-panel {
    top: 8px;
    width: min(520px, calc(100vw - 20px));
    padding: 10px 12px 12px;
  }

  .kicker {
    margin-bottom: 6px;
    font-size: 11px;
  }

  h1 {
    margin-bottom: 8px;
    font-size: clamp(30px, 7vh, 46px);
  }

  .primary-action {
    min-width: 118px;
    padding: 8px 12px 11px;
    font-size: 12px;
  }

  .dialog {
    right: 10px;
    bottom: 8px;
    left: 10px;
    min-height: 118px;
    max-height: calc(100% - 16px);
    padding: 10px 12px 54px;
    border-width: 4px;
    outline-width: 3px;
    box-shadow:
      inset 0 0 0 3px var(--panel-dark),
      0 8px 0 rgba(48, 23, 12, 0.42),
      0 12px 22px var(--shadow);
  }

  .speaker-row {
    gap: 8px;
    margin-bottom: 7px;
  }

  .speaker,
  .chapter {
    padding: 6px 7px 8px;
    font-size: 11px;
  }

  .dialog-text {
    min-height: 0;
    font-size: clamp(13px, 3.2vh, 16px);
    line-height: 1.14;
  }

  .continue {
    right: 12px;
    bottom: 10px;
    min-width: 116px;
    padding: 8px 10px 11px;
    font-size: 11px;
  }
}
