/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #f8f8f8;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Layout ── */
#gameWrapper {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 960px;
}
/* ── Shared box style for mission + dialog ── */
.pixel-box {
  background: #f8f8f8;
  border: 3px solid #303030;
  padding: 10px 14px;
  color: #303030;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #b0b0b0;
  font-family: 'Press Start 2P', 'Courier New', monospace;
}

/* ── Mission bar ── */
#missionBar {
  border-bottom: none;
}

#missionBar .mission-title {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.mission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #303030;
  padding-bottom: 5px;
  margin-bottom: 8px;
}

#skipBtn {
  padding: 4px 10px;
  border: 2px solid #303030;
  border-radius: 0;
  background: #404040;
  color: #f8f8f8;
  cursor: pointer;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 7px;
  text-transform: uppercase;
  box-shadow: inset 1px 1px 0 #606060, inset -1px -1px 0 #202020;
}

#skipBtn:hover {
  background: #505050;
}

.mission-buttons {
  display: flex;
  gap: 6px;
}

#hintBtn {
  padding: 4px 10px;
  border: 2px solid #d4a017;
  border-radius: 0;
  background: #d4a017;
  color: #303030;
  cursor: pointer;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 7px;
  text-transform: uppercase;
  box-shadow: inset 1px 1px 0 #e8c040, inset -1px -1px 0 #a07010;
}

#hintBtn:hover {
  background: #e8c040;
}

#hintBtn:disabled {
  background: #999;
  border-color: #777;
  color: #555;
  cursor: default;
}

#hintBox {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  background: #f8f8f8;
  border: 3px solid #303030;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #b0b0b0;
  font-size: 9px;
  line-height: 1.8;
  z-index: 8;
  text-align: center;
  min-width: 200px;
}

#hintBox .hint-pinyin {
  color: #2060a0;
  font-size: 11px;
  font-style: italic;
  margin-bottom: 4px;
}

#hintBox .hint-chinese {
  color: #303030;
  font-size: 14px;
  margin-bottom: 4px;
}

#hintBox .hint-english {
  color: #707070;
  font-size: 9px;
}

#missionList {
  list-style: none;
}

#missionList li {
  font-size: 10px;
  line-height: 2;
  color: #404040;
}

#missionList li::before {
  content: '▸ ';
  color: #d4a017;
}

/* ── Game container ── */
#gameContainer {
  position: relative;
  width: 100%;
  aspect-ratio: 400 / 225;
  border-left: 3px solid #303030;
  border-right: 3px solid #303030;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: filter 0.4s ease;
}

#gameCanvas.blurred {
  filter: blur(3px) brightness(0.7);
}

#uiOverlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ── Dialog box — below game, same style as mission ── */

.portrait-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 8px;
  pointer-events: none;
  z-index: 5;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
}

.portrait-bar.active {
  transform: translateY(0);
}

.portrait {
  height: 240px;
  width: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

#dialogContainer {
  display: block;
  width: 100%;
  z-index: 10;
  pointer-events: none;
  visibility: visible;
  min-height: 120px;
}

#dialogContainer.active {
  pointer-events: auto;
}

#dialogContainer .dialog-box {
  background: #f8f8f8;
  border: 3px solid #303030;
  border-top: none;
  border-radius: 0;
  padding: 10px 14px;
  color: #303030;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #b0b0b0;
  height: 130px;
  display: flex;
  flex-direction: column;
}

#dialogContainer .dialog-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#dialogContainer .npc-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #303030;
  padding-bottom: 5px;
  margin-bottom: 8px;
}

#dialogContainer .greeting-text {
  font-size: 14px;
  line-height: 2;
  margin-bottom: 12px;
  color: #202020;
}

#dialogContainer .transcript-area {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.8;
}

#dialogContainer .transcript-entry { margin-bottom: 4px; }
#dialogContainer .transcript-entry.player { color: #2060a0; }
#dialogContainer .transcript-entry.npc { color: #303030; }

#dialogContainer .dialog-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#dialogContainer .dialog-buttons button {
  padding: 8px 16px;
  border: 2px solid #303030;
  border-radius: 0;
  background: #404040;
  color: #f8f8f8;
  cursor: pointer;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 9px;
  text-transform: uppercase;
  box-shadow: inset 1px 1px 0 #606060, inset -1px -1px 0 #202020;
}

#dialogContainer .dialog-buttons button:hover { background: #505050; }
#dialogContainer .dialog-buttons button:active {
  background: #303030;
  box-shadow: inset 1px 1px 0 #202020, inset -1px -1px 0 #404040;
}

#dialogContainer .dialog-buttons button.recording {
  background: #8b2020;
  color: #fff;
}

#dialogContainer .dialog-status {
  font-size: 8px;
  color: #707070;
  margin-bottom: 4px;
  font-style: italic;
}

/* ── Mobile Controls ── */

#transitionScreen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 100;
  justify-content: center;
  align-items: center;
}

#transitionScreen.active {
  display: flex;
}

#transitionContent {
  text-align: center;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: #f8f8f8;
}

#transitionCity {
  font-size: 16px;
  margin-bottom: 20px;
  line-height: 2;
}

#transitionTime {
  font-size: 11px;
  margin-bottom: 30px;
  color: #aaa;
}

#transitionContinue {
  padding: 10px 24px;
  border: 3px solid #f8f8f8;
  border-radius: 0;
  background: transparent;
  color: #f8f8f8;
  cursor: pointer;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 10px;
  text-transform: uppercase;
}

#transitionContinue:hover {
  background: #222;
}

#mobileControls {
  display: none;
  width: 100%;
  padding: 10px 16px;
  justify-content: space-between;
  align-items: center;
  background: #1a1a1a;
  border: 3px solid #303030;
  border-top: none;
}

#mobileControls.active { display: flex; }

#mobileControls .dpad {
  display: grid;
  grid-template-columns: 44px 44px 44px;
  grid-template-rows: 44px 44px 44px;
  gap: 2px;
}

#mobileControls .dpad .dpad-btn {
  width: 44px; height: 44px;
  background: #303030;
  border: 2px solid #505050;
  border-radius: 0;
  color: #f8f8f8;
  font-size: 18px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

#mobileControls .dpad .dpad-btn:active { background: #505050; }
#mobileControls .dpad .empty { visibility: hidden; }

#mobileControls .interact-btn {
  width: 70px; height: 70px;
  background: #303030;
  border: 3px solid #505050;
  border-radius: 0;
  color: #f8f8f8;
  font-size: 10px;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

#mobileControls .interact-btn:active { background: #505050; }
#touchControls { display: none !important; }
