* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: #000;
  font-family: 'Be Vietnam Pro', sans-serif;
  color: #f1f5f9;
  overflow: hidden;
}

/* Căn giữa khung 16:9 hoàn hảo trên mọi kích thước màn hình */
#viewport-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-container {
  position: relative;
  width: min(100vw, 177.78vh);
  height: min(56.25vw, 100vh);
  background: #0f172a;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.9);
}

#canvas-holder, #canvas-holder canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Quản lý các màn hình */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Màn hình Tiêu đề */
#screen-title {
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
  text-align: center;
}

.game-title {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 800;
  letter-spacing: 3px;
  color: #fbbf24;
  text-shadow: 0 6px 20px rgba(251, 191, 36, 0.35);
  margin-bottom: 0.6rem;
}

.game-subtitle {
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  color: #94a3b8;
  margin-bottom: 2.5rem;
}

/* Nút bấm */
.btn {
  font-family: inherit;
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  font-weight: 600;
  padding: 0.8em 1.8em;
  border-radius: 10px;
  border: 2px solid #475569;
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:hover {
  transform: translateY(-2px);
  background: #334155;
  border-color: #94a3b8;
}

.primary-btn {
  background: #f59e0b;
  border-color: #fbbf24;
  color: #0f172a;
  font-weight: 800;
}

.primary-btn:hover {
  background: #fbbf24;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.small-btn {
  position: absolute;
  bottom: 4%;
  right: 3%;
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  padding: 0.5em 1.1em;
  z-index: 25;
  opacity: 0.85;
}

/* Video & Lựa chọn */
#introVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 20, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(3px);
}

.choice-prompt {
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  margin-bottom: 1.8rem;
  color: #e2e8f0;
  font-weight: 600;
}

.choice-buttons {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.key-hint {
  color: #fde68a;
  margin-right: 6px;
}

.primary-btn .key-hint {
  color: #451a03;
}

/* Giao diện HUD trong cảnh 3D */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.hud-box {
  position: absolute;
  top: 4%;
  padding: 0.5em 1em;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  font-weight: 800;
  font-size: clamp(1rem, 1.8vw, 1.4rem);
}

#hud-top-left {
  left: 3%;
  color: #38bdf8;
}

#hud-timer {
  right: 3%;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
}

#hud-timer.danger {
  color: #ef4444;
  border-color: #ef4444;
  animation: pulse 0.8s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

#floating-penalty {
  position: absolute;
  top: 12%;
  right: 4%;
  color: #ef4444;
  font-weight: 800;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  animation: floatUp 1.2s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-25px); }
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px #000;
}

#interact-prompt {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  color: #fbbf24;
  padding: 0.35em 0.9em;
  border-radius: 6px;
  font-weight: 600;
  font-size: clamp(0.85rem, 1.3vw, 1.05rem);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

#subtitle-box {
  position: absolute;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  text-align: center;
  background: rgba(9, 13, 22, 0.88);
  color: #f8fafc;
  padding: 0.7em 1.4em;
  border-radius: 10px;
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  border-left: 4px solid #fbbf24;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

#loudspeaker-bar {
  position: absolute;
  bottom: 1.5%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.85);
  color: #fde047;
  padding: 0.3em 1.2em;
  border-radius: 20px;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  font-style: italic;
}

/* Tờ giấy danh sách & Bảng điện tử */
.modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fef3c7;
  color: #1e293b;
  padding: 1.8rem 2.2rem;
  border-radius: 12px;
  min-width: 320px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.8);
  z-index: 30;
}

.modal-card h3 {
  text-align: center;
  margin-bottom: 1rem;
  border-bottom: 2px dashed #94a3b8;
  padding-bottom: 0.5rem;
}

#checklist-items {
  list-style: none;
  font-size: 1.05rem;
  line-height: 2;
}

#checklist-items li.checked {
  text-decoration: line-through;
  color: #15803d;
  font-weight: 600;
}

.board-style {
  background: #090d16;
  color: #f59e0b;
  border: 3px solid #334155;
  min-width: 55%;
}

.board-style h3 {
  color: #fbbf24;
  border-bottom: 1px solid #334155;
  letter-spacing: 1px;
}

.board-style table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
}

.board-style th, .board-style td {
  padding: 0.5em 0.8em;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

.board-style tr.dimmed {
  color: #64748b;
}

.modal-hint {
  text-align: center;
  margin-top: 1.2rem;
  font-size: 0.85rem;
  opacity: 0.75;
}

.pause-box {
  background: #1e293b;
  padding: 1rem 2rem;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 600;
  border: 2px solid #fbbf24;
  cursor: pointer;
  pointer-events: auto;
}

/* Màn hình chuyển cảnh & Game Over */
#transition-card, #screen-gameover {
  background: #000;
  z-index: 40;
  text-align: center;
}

#transition-text {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  color: #f8fafc;
  letter-spacing: 1px;
}

.gameover-title {
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  color: #ef4444;
  margin-bottom: 1rem;
}

#gameover-reason {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: #cbd5e1;
  margin-bottom: 2rem;
  max-width: 75%;
}

/* Màn hình Credits cuối game */
#ending-credits {
  position: absolute;
  top: 0;
  right: 0;
  width: 52%;
  height: 100%;
  background: linear-gradient(to left, rgba(9, 13, 22, 0.92) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5%;
  z-index: 35;
}

.credits-panel {
  max-width: 440px;
  text-align: left;
}

.credits-panel h2 {
  color: #fbbf24;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  margin-bottom: 0.6rem;
}

.credits-quote {
  color: #e2e8f0;
  font-style: italic;
  margin-bottom: 1.5rem;
}

.stats-box {
  background: rgba(30, 41, 59, 0.8);
  padding: 1rem 1.2rem;
  border-radius: 10px;
  border-left: 4px solid #38bdf8;
  margin-bottom: 1.8rem;
  line-height: 1.8;
  font-size: 0.95rem;
}

.credits-buttons {
  display: flex;
  gap: 1rem;
}