/* ==========================================================================
   THEO DẤU CHÂN NGƯỜI (1911–1945) — Vintage Watercolor Journal UI
   Zero backdrop-filter, Mobile-first 60 FPS, Touch-friendly!
   ========================================================================== */
:root {
  --paper: #f6eedb;
  --paper-deep: #eadbc0;
  --paper-dark: #dcc6a0;
  --ink: #2b1f16;
  --ink-soft: #5c4634;
  --bronze: #8b5e34;
  --crimson: #b9382c;
  --crimson-dark: #8e261d;
  --ocean: #244f6b;
  --ocean-deep: #153144;
  --gold: #c98a2c;
  --forest: #2f5d42;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  width: 100%; height: 100%; height: 100dvh; overflow: hidden;
  overscroll-behavior: none; touch-action: manipulation;
  background: var(--ocean-deep); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.hidden { display: none !important; }

/* Buttons */
.btn {
  border: 2px solid var(--bronze);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(43, 31, 22, 0.25);
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:hover:not(:disabled) { background: #fff9eb; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(43, 31, 22, 0.25); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; white-space: nowrap; line-height: 1.15; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-primary { background: var(--crimson); border-color: var(--crimson-dark); color: #fffaf0; }
.btn-primary:hover:not(:disabled) { background: #cc4134; }
.btn-amber { background: #e8be6c; border-color: #9e6b1b; color: #2b1a08; }
.btn-amber:hover:not(:disabled) { background: #f2cb7c; }

/* Top Bar */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px;
  background: rgba(246, 238, 219, 0.96);
  border-bottom: 2px solid var(--bronze);
  box-shadow: 0 4px 14px rgba(21, 49, 68, 0.28);
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 6px; }
.top-pill {
  font-family: "Times New Roman", "Cambria", serif;
  font-weight: 900; font-size: 14px; letter-spacing: 0.06em;
  color: var(--crimson-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Fullscreen Containers */
.screen { position: fixed; inset: 0; width: 100%; height: 100%; }

/* 1. TITLE SCREEN */
.title-screen {
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background:
    linear-gradient(180deg, rgba(18, 30, 42, 0.52) 0%, rgba(14, 24, 34, 0.68) 100%),
    url('art/cgs/nha_rong.jpg') center/cover no-repeat,
    radial-gradient(circle at 50% 35%, #2b5b7a 0%, #173347 62%, #0e202e 100%);
}
.paper-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.14;
  background-image: radial-gradient(rgba(255, 244, 214, 0.5) 1px, transparent 1px);
  background-size: 20px 20px;
}
.title-frame {
  position: relative; z-index: 2;
  width: min(720px, 95vw);
  background: linear-gradient(180deg, rgba(250, 243, 227, 0.94) 0%, rgba(234, 219, 192, 0.94) 100%);
  border: 3px solid var(--bronze);
  border-radius: 18px;
  padding: 28px 30px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62), inset 0 0 0 6px rgba(139, 94, 52, 0.18);
}

/* Smooth Story CG Cross-fade */
@keyframes cgFadeIn {
  from { opacity: 0.42; }
  to { opacity: 1; }
}
.cg-fade-in { animation: cgFadeIn 0.34s ease-out; }

/* Epilogue / Grand Finale Screen */
.epilogue-screen {
  display: flex; align-items: center; justify-content: center; padding: 66px 16px 20px;
  background:
    linear-gradient(180deg, rgba(28, 14, 10, 0.56) 0%, rgba(16, 10, 8, 0.78) 100%),
    url('art/cgs/badinh_1945.jpg') center/cover no-repeat;
  overflow-y: auto;
}
.epilogue-card {
  width: min(760px, 95vw);
  background: linear-gradient(180deg, rgba(251, 244, 229, 0.97) 0%, rgba(235, 219, 191, 0.97) 100%);
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 28px 30px 24px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), inset 0 0 0 6px rgba(201, 138, 44, 0.2);
}
.epilogue-title {
  font-family: "Times New Roman", "Cambria", serif;
  font-size: clamp(22px, 3.6vw, 34px);
  color: var(--crimson-dark); margin: 4px 0 10px; letter-spacing: 0.03em;
}
.ep-stars {
  display: inline-block; padding: 6px 18px; border-radius: 999px;
  background: var(--crimson); color: #fef08a; font-weight: 900; font-size: 14px;
  letter-spacing: 0.06em; margin-bottom: 14px;
}
.ep-quote {
  font-family: "Times New Roman", "Cambria", serif; font-style: italic;
  font-size: 16.5px; line-height: 1.62; color: var(--ink);
  background: rgba(185, 56, 44, 0.08); border-left: 4px solid var(--crimson);
  padding: 12px 16px; border-radius: 8px; text-align: left; margin-bottom: 16px;
}
.ep-timeline {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px;
}
.ep-timeline span {
  background: rgba(139, 94, 52, 0.13); border: 1px solid var(--bronze);
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; color: var(--ocean-deep);
}
.ep-thanks {
  font-size: 14px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 18px; font-weight: 600;
}
.title-stamp {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(185, 56, 44, 0.12); border: 1.5px solid var(--crimson);
  color: var(--crimson-dark); font-size: 11px; font-weight: 900; letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.game-title {
  font-family: "Times New Roman", "Cambria", serif;
  font-size: clamp(30px, 5.2vw, 52px);
  color: var(--ink); letter-spacing: 0.03em; line-height: 1.1;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}
.game-subtitle {
  margin: 12px auto 0; max-width: 560px;
  font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); font-weight: 500;
}
.title-ornament {
  margin: 16px auto 20px; padding: 8px 14px; border-radius: 10px;
  background: rgba(139, 94, 52, 0.1); border: 1px dashed var(--bronze);
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  font-size: 12.5px; font-weight: 800; color: var(--ocean-deep);
}
.title-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.title-actions > .btn-lg { width: min(360px, 100%); }
.title-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.title-foot {
  margin-top: 20px; padding-top: 12px; border-top: 1px solid rgba(139, 94, 52, 0.28);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}

/* 2. MAP SCREEN */
.map-screen { padding-top: 52px; background: #dfd0b2; }
.map-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
.map-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.map-card {
  position: absolute; left: 16px; bottom: 16px; width: min(370px, calc(100vw - 32px));
  background: rgba(249, 242, 226, 0.97);
  border: 2.5px solid var(--bronze); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 12px 32px rgba(21, 49, 68, 0.35);
}
.map-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.year-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--crimson); color: #fffaf0; font-size: 11px; font-weight: 900; letter-spacing: 0.05em;
}
.stars-badge { font-size: 16px; color: var(--gold); letter-spacing: 2px; font-weight: 900; }
.map-card h2 { font-family: "Times New Roman", "Cambria", serif; font-size: 19px; color: var(--ink); margin-bottom: 3px; }
.mc-loc { font-size: 12px; font-weight: 800; color: var(--ocean); margin-bottom: 6px; }
.mc-desc { font-size: 13px; line-height: 1.45; color: var(--ink-soft); margin-bottom: 8px; }
.mc-mg-tag {
  padding: 6px 10px; border-radius: 8px; margin-bottom: 10px;
  background: rgba(36, 79, 107, 0.1); border-left: 3.5px solid var(--ocean);
  font-size: 12px; font-weight: 800; color: var(--ocean-deep);
}
.mc-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.mc-btns .btn-primary { flex: 1; }

/* 3. STORY SCREEN */
.story-screen { padding-top: 52px; background: #1e2d3a; }
.story-stage { position: relative; width: 100%; height: 100%; overflow: hidden; }
.story-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.story-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; pointer-events: none; }
.story-header {
  position: absolute; top: 12px; left: 16px; right: 16px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: nowrap;
}
.st-loc {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 800; font-size: 13px; color: #fff7e6;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.75); letter-spacing: 0.04em;
}
.story-box {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 6;
  width: min(860px, calc(100vw - 24px));
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(180deg, rgba(251, 245, 232, 0.96) 0%, rgba(241, 229, 205, 0.96) 100%);
  border: 2.5px solid var(--bronze); border-radius: 16px; padding: 16px 20px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(139, 94, 52, 0.14);
  cursor: pointer;
}
.st-avatar {
  width: 72px; height: 72px; flex-shrink: 0; border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #fffaf0, var(--paper-deep));
  border: 2.5px solid var(--bronze);
  box-shadow: 0 4px 12px rgba(43, 31, 22, 0.22);
  display: grid; place-items: center; font-size: 28px;
}
.st-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-content { flex: 1; min-width: 0; }
.st-speaker {
  font-family: "Times New Roman", "Cambria", serif; font-size: 15px; font-weight: 900;
  color: var(--crimson-dark); margin-bottom: 5px; letter-spacing: 0.04em;
}
.st-text { font-size: 15.5px; line-height: 1.55; color: var(--ink); min-height: 48px; font-weight: 500; }
.st-hint { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); text-align: right; }

/* 4. MINIGAME SCREEN */
.mg-screen { padding-top: 52px; display: flex; flex-direction: column; background: #1d2c3a; }
.mg-hud {
  height: 46px; padding: 0 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--paper-deep); border-bottom: 2px solid var(--bronze);
}
.mg-hud-left, .mg-hud-center, .mg-hud-right { display: flex; align-items: center; gap: 8px; }
.mg-stat { font-size: 13px; font-weight: 800; color: var(--ocean-deep); }
.mg-timer {
  font-family: monospace; font-size: 16px; font-weight: 900; color: var(--crimson-dark);
  padding: 2px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid var(--bronze);
}
.mg-stage-wrap { position: relative; flex: 1; width: 100%; overflow: hidden; }
.mg-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.mg-overlay-root { position: absolute; inset: 0; pointer-events: none; }
.mg-overlay-root > * { pointer-events: auto; }

/* MODALS */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; padding: 16px;
  background: rgba(15, 28, 38, 0.76);
  display: flex; align-items: center; justify-content: center;
}
.journal-modal {
  width: min(560px, 95vw); max-height: 88vh; overflow-y: auto;
  background: var(--paper); border: 3px solid var(--bronze); border-radius: 16px;
  padding: 22px 24px; text-align: center;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.55);
}
.journal-modal.wide { width: min(860px, 95vw); text-align: left; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.journal-modal h2 { font-family: "Times New Roman", "Cambria", serif; font-size: 23px; color: var(--ink); margin-bottom: 8px; }
.modal-p { font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 14px; }
.brief-steps {
  text-align: left; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
  background: rgba(139, 94, 52, 0.1); border: 1.5px solid rgba(139, 94, 52, 0.35);
  font-size: 13.5px; color: var(--ink);
}
.mgr-stars { font-size: 38px; color: var(--gold); letter-spacing: 6px; margin: 4px 0 10px; }
.modal-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* Journal & Arcade Grids */
.journal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.archive-card {
  background: #fffaf0; border: 2px solid var(--bronze); border-radius: 12px; padding: 13px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.archive-card.locked { opacity: 0.62; background: var(--paper-deep); border-style: dashed; }
.archive-card h3 { font-family: "Times New Roman", "Cambria", serif; font-size: 16px; color: var(--ink); }
.archive-card p { font-size: 12.8px; line-height: 1.5; color: var(--ink-soft); }
.archive-quote {
  padding: 7px 10px; border-left: 3px solid var(--crimson); background: rgba(185, 56, 44, 0.08);
  font-style: italic; font-size: 12.2px; color: var(--ink); border-radius: 0 6px 6px 0;
}

/* Mobile Responsive Polish — Portrait Phones */
@media (max-width: 720px) {
  .top-bar { height: 44px; padding: 0 6px; gap: 4px; }
  .bar-left, .bar-right { gap: 4px; }
  .top-bar .btn-sm { padding: 5px 7px; font-size: 11px; border-width: 1.5px; }
  .top-pill { display: none; }
  .map-screen, .story-screen, .mg-screen { padding-top: 44px; }
  .title-frame { padding: 18px 16px 14px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .story-header { top: 8px; left: 10px; right: 10px; gap: 6px; }
  .story-header .year-badge { font-size: 10px; padding: 2px 8px; flex-shrink: 0; }
  .story-header .st-loc { font-size: 11px; }
  .story-header .btn-sm { padding: 4px 8px; font-size: 11px; }
  .story-box { padding: 10px 12px; gap: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); border-radius: 14px; }
  .st-avatar { width: 48px; height: 48px; font-size: 22px; border-radius: 10px; }
  .st-speaker { font-size: 13px; margin-bottom: 3px; }
  .st-text { font-size: 13.5px; line-height: 1.45; min-height: 36px; }
  .st-hint { margin-top: 5px; font-size: 10.5px; }
  .map-card { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto; padding: 11px 13px; }
  .mg-hud { height: 38px; padding: 0 6px; gap: 4px; }
  .mg-hud .year-badge { display: none; }
  .mg-stat { font-size: 11px; }
  .mg-timer { font-size: 13px; padding: 2px 6px; }
}

/* Mobile Responsive Polish — Short Landscape Phones (iPhone / Android xoay ngang!) */
@media (max-height: 520px) {
  .top-bar { height: 36px; padding: 0 8px; gap: 6px; }
  .top-bar .btn-sm { padding: 3px 8px; font-size: 11px; border-width: 1.5px; }
  .top-pill { font-size: 11.5px; }
  .map-screen, .story-screen, .mg-screen { padding-top: 36px; }
  .title-frame, .epilogue-card { padding: 14px 18px 12px; max-height: calc(100dvh - 16px); overflow-y: auto; }
  .game-title { font-size: 26px; }
  .game-subtitle { font-size: 12.5px; margin-top: 6px; }
  .title-ornament { margin: 8px auto 10px; padding: 5px 10px; font-size: 11px; }
  .story-header { top: 6px; left: 10px; right: 10px; gap: 8px; }
  .story-header .year-badge { font-size: 10px; padding: 2px 8px; flex-shrink: 0; }
  .story-header .st-loc { font-size: 11px; }
  .story-header .btn-sm { padding: 3px 8px; font-size: 10.5px; }
  .story-box {
    bottom: 6px; padding: 7px 12px; gap: 10px; border-radius: 12px;
    width: min(760px, calc(100vw - 24px));
    background: linear-gradient(180deg, rgba(251, 245, 232, 0.90) 0%, rgba(241, 229, 205, 0.90) 100%);
  }
  .st-avatar { width: 42px; height: 42px; font-size: 20px; border-radius: 10px; border-width: 2px; }
  .st-speaker { font-size: 12px; margin-bottom: 2px; }
  .st-text { font-size: 12.5px; line-height: 1.38; min-height: 0; max-height: 54px; overflow-y: auto; }
  .st-hint { display: none; }
  .map-card { bottom: 8px; left: 10px; padding: 9px 12px; width: min(330px, 46vw); }
  .map-card h2 { font-size: 15px; }
  .mc-desc { font-size: 11.5px; margin-bottom: 5px; }
  .mg-hud { height: 34px; padding: 0 8px; }
  .mg-stat { font-size: 11px; }
  .mg-timer { font-size: 13px; padding: 1px 6px; }
  .journal-modal { padding: 14px 16px; max-height: calc(100dvh - 16px); }
}
