/* === THE ENCOUNTER — Style === */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --void: #0c0b14;
  --void-light: #15132a;
  --panel-bg: rgba(8, 6, 18, 0.94);
  --border: #3a3050;
  --border-inner: #4a4065;
  --gold: #d4a84f;
  --gold-dim: #a07a30;
  --text: #c8c0d8;
  --text-dim: #6a6080;
  --pixel-font: 'Press Start 2P', monospace;
  --body-font: system-ui, -apple-system, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--body-font);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* === Screens === */
#game {
  width: 100%;
  height: calc(100dvh - 50px);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* === Canvas === */
canvas {
  display: block;
  width: 100%;
  flex: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* === Pixel text class === */
.pixel-text {
  font-family: var(--pixel-font);
  font-size: 10px;
  line-height: 1.8;
  letter-spacing: 0.5px;
}

/* === Dialog box (JRPG style) === */
.dialog-box {
  border: 2px solid var(--border);
  outline: 2px solid var(--void);
  background: var(--panel-bg);
  padding: 14px 16px;
  position: relative;
}

.dialog-box::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid var(--border-inner);
  pointer-events: none;
  border-radius: 1px;
}

/* === Entry screen === */
#entry {
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#entry-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#entry-ui {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  width: 100%;
  max-width: 360px;
}

#entry-dialog {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
}

#npc-portrait {
  width: 52px;
  height: 102px;
  flex-shrink: 0;
  border: 1px solid var(--border-inner);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: rgba(5, 4, 12, 0.6);
}

#entry-text {
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  min-height: 2em;
  white-space: pre-wrap;
  flex: 1;
}

#tap-continue {
  color: var(--gold);
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

/* Color choice buttons */
#color-choices {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.color-btn {
  font-family: var(--pixel-font);
  font-size: 9px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.color-btn:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.6);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* === Experience screen === */
#experience {
  flex-direction: column;
}

#main-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#prompt-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(to bottom, transparent 0%, var(--void) 30%);
  padding-top: 30px;
  max-height: 55%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Step dots */
#step-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--border);
  transition: background 0.5s ease;
}

.dot.active {
  background: var(--gold);
}

.dot.done {
  background: var(--gold-dim);
}

/* Prompt text */
#prompt-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  min-height: 2em;
  white-space: pre-wrap;
}

/* Textarea */
#response {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  background: rgba(15, 12, 28, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.6;
  padding: 10px 12px;
  resize: none;
  outline: none;
  transition: opacity 0.5s ease;
}

#response:focus {
  border-color: var(--gold-dim);
}

#response::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

/* Continue button */
#continue-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 9px;
}

#continue-btn:hover {
  background: rgba(212, 168, 79, 0.1);
  border-color: var(--gold);
}

/* === Summary screen === */
#summary-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#summary-scroll {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(to bottom, rgba(245, 238, 220, 0.95), rgba(235, 228, 210, 0.98));
}

#summary-content {
  padding: 40px 20px 60px;
  max-width: 380px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.summary-block {
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.8s ease;
}

.summary-block.visible {
  opacity: 1;
  transform: translateY(0);
}

.summary-label {
  font-family: var(--pixel-font);
  font-size: 7px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a7040;
  margin-bottom: 6px;
}

.summary-answer {
  font-size: 15px;
  line-height: 1.7;
  color: #3a3028;
  white-space: pre-wrap;
  border-left: 2px solid #c8a860;
  padding-left: 14px;
}

.summary-name {
  font-size: 22px;
  color: #6a5530;
  font-family: var(--pixel-font);
  text-align: center;
  padding: 20px 0;
}

.summary-closing {
  font-size: 15px;
  line-height: 1.8;
  color: #7a6a50;
  text-align: center;
  padding: 30px 0;
  border-top: 1px solid #d0c0a0;
}

.summary-cta {
  text-align: center;
  padding: 10px 0 30px;
}

.summary-cta a {
  font-family: var(--pixel-font);
  font-size: 9px;
  color: #6a5530;
  text-decoration: none;
  border: 1px solid #b8a060;
  padding: 10px 20px;
  transition: all 0.3s ease;
  display: inline-block;
}

.summary-cta a:hover {
  background: rgba(180, 150, 80, 0.15);
}

/* === Utility === */
.hidden {
  opacity: 0;
  pointer-events: none;
}

.hidden-hard {
  display: none;
}

/* === Fallback for browsers without dvh support === */
@supports not (height: 1dvh) {
  #game {
    height: calc(100vh - 50px);
  }
}