/* ============================================
   分身检测员 (Doppelgänger Detector)
   1955 Retro Chinese Aesthetic
   ============================================ */

/* --- CSS Variables --- */
:root {
  --bg-dark: #1a1410;
  --bg-medium: #2d2418;
  --bg-light: #3d3225;
  --text-primary: #e8d5b7;
  --text-secondary: #a89070;
  --text-accent: #f0c040;
  --primary: #c4956a;
  --danger: #c0392b;
  --success: #27ae60;
  --warning: #f39c12;
  --brass: #b8860b;
  --brass-light: #d4a843;
  --wood-dark: #3b2a1a;
  --wood-medium: #5c3d2e;
  --wood-light: #7a5a3a;
  --paper-old: #d4c5a0;
  --paper-dark: #b8a882;
  --ink-black: #1a1008;
  --ink-red: #8b1a1a;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Noto Serif SC", "SimSun", "STSong", "Songti SC", serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; }

/* --- Utility --- */
.hidden { display: none !important; }

.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ============================================
   #loading-screen
   ============================================ */
#loading-screen {
  background: var(--bg-dark);
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#loading-screen .loading-title {
  font-size: 2.4rem;
  color: var(--text-accent);
  margin-bottom: 2rem;
  letter-spacing: 0.3em;
  text-shadow: 0 0 20px rgba(240, 192, 64, 0.4);
}

#loading-screen .loading-bar-container {
  width: 320px;
  height: 12px;
  background: var(--bg-light);
  border-radius: 6px;
  border: 1px solid var(--wood-medium);
  overflow: hidden;
  position: relative;
}

#loading-screen .loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brass), var(--brass-light), var(--brass));
  border-radius: 6px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.5);
}

#loading-screen .loading-status {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
}

#loading-screen .loading-substatus {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ============================================
   #menu-screen
   ============================================ */
#menu-screen {
  background:
    linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.8) 100%),
    var(--bg-dark);
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Building silhouette background */
#menu-screen::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40%;
  background:
    linear-gradient(0deg, #0a0a08 0%, transparent 100%),
    /* Building 1 */
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 5% bottom / 8% 35%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 14% bottom / 6% 28%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 22% bottom / 10% 42%,
    /* Building 2 - pagoda style */
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 35% bottom / 5% 50%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 33% bottom / 9% 38%,
    /* Building 3 */
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 50% bottom / 12% 30%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 55% bottom / 7% 45%,
    /* Building 4 */
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 68% bottom / 9% 33%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 75% bottom / 6% 48%,
    /* Building 5 */
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 85% bottom / 11% 36%,
    linear-gradient(0deg, #12100c 60%, transparent 60%) no-repeat 93% bottom / 7% 25%;
  pointer-events: none;
  opacity: 0.7;
}

#menu-screen .menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  animation: fadeIn 1s ease;
}

#menu-screen .menu-title {
  font-size: 4rem;
  color: var(--text-accent);
  letter-spacing: 0.5em;
  text-shadow:
    0 0 30px rgba(240, 192, 64, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.8),
    2px 2px 0 var(--brass);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

#menu-screen .menu-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.3em;
  margin-bottom: 3rem;
  font-style: italic;
}

#menu-screen .menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 280px;
}

#menu-screen .menu-buttons .btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
}

#menu-screen .menu-version {
  position: absolute;
  bottom: 1rem;
  right: 1.5rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.4;
}

/* ============================================
   #game-screen
   ============================================ */
#game-screen {
  background: var(--bg-dark);
  display: none;
  flex-direction: column;
}

#game-screen.active {
  display: flex;
}

/* --- HUD --- */
#game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.2rem;
  background:
    linear-gradient(180deg, var(--wood-dark) 0%, var(--wood-medium) 50%, var(--wood-dark) 100%);
  border-bottom: 2px solid var(--brass);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  height: 48px;
  flex-shrink: 0;
  z-index: 10;
}

#game-hud > div {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.hud-level {
  color: var(--text-accent);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.hud-score {
  color: var(--text-primary);
}

.hud-score .score-value {
  color: var(--text-accent);
  font-weight: 700;
}

.hud-lives {
  color: var(--danger);
  font-size: 1rem;
  letter-spacing: 0.15em;
}

.hud-lives .heart-empty {
  opacity: 0.3;
}

.hud-timer {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: center;
}

.hud-timer.timer-warning {
  color: var(--warning);
  animation: pulse 0.8s ease infinite;
}

.hud-timer.timer-danger {
  color: var(--danger);
  animation: pulse 0.4s ease infinite;
}

.hud-combo {
  color: var(--text-accent);
  font-weight: 700;
}

.hud-combo.combo-active {
  animation: pulse 0.6s ease infinite;
  text-shadow: 0 0 10px rgba(240, 192, 64, 0.6);
}

/* --- Game Layout (below HUD) --- */
#game-screen .game-layout {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  flex: 1;
  overflow: hidden;
}

/* --- Visitor Panel (Left) --- */
#visitor-panel {
  background:
    linear-gradient(135deg, var(--bg-medium) 0%, var(--bg-dark) 100%);
  border-right: 2px solid var(--wood-medium);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.8rem;
  gap: 0.8rem;
  overflow-y: auto;
}

#visitor-panel .panel-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--wood-medium);
  padding-bottom: 0.4rem;
  width: 100%;
  text-align: center;
}

.portrait-frame {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--brass);
  box-shadow:
    0 0 0 2px var(--wood-dark),
    0 0 0 6px var(--brass-light),
    0 0 0 8px var(--wood-dark),
    0 4px 12px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.portrait-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.portrait-body {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: var(--primary);
  position: relative;
}

.portrait-body .portrait-head {
  width: 45%;
  height: 45%;
  border-radius: 50%;
  background: inherit;
  filter: brightness(1.15);
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
}

.portrait-body .portrait-torso {
  width: 70%;
  height: 40%;
  border-radius: 50% 50% 0 0;
  background: inherit;
  filter: brightness(0.85);
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.visitor-info {
  text-align: center;
  width: 100%;
}

.visitor-info .visitor-name {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.visitor-info .visitor-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.visitor-queue {
  margin-top: auto;
  padding: 0.5rem 1rem;
  background: var(--bg-light);
  border-radius: 4px;
  border: 1px solid var(--wood-medium);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
}

.visitor-queue .queue-count {
  color: var(--text-accent);
  font-weight: 700;
  font-size: 1.2rem;
}

/* --- Work Area (Center) --- */
#work-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-medium);
  overflow: hidden;
}

#document-area {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-content: flex-start;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 30px,
      rgba(0,0,0,0.03) 30px,
      rgba(0,0,0,0.03) 31px
    ),
    linear-gradient(135deg, var(--bg-medium) 0%, var(--bg-light) 100%);
}

#dialogue-area {
  height: 180px;
  min-height: 140px;
  border-top: 2px solid var(--wood-medium);
  background:
    linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
  padding: 0.8rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* --- Action Panel (Right) --- */
#action-panel {
  background:
    linear-gradient(180deg, var(--wood-dark) 0%, #2a1f14 50%, var(--wood-dark) 100%);
  border-left: 2px solid var(--wood-medium);
  display: flex;
  flex-direction: column;
  padding: 0.8rem;
  gap: 0.6rem;
  overflow-y: auto;
}

#action-panel .panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#action-panel .panel-section-title {
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--wood-medium);
  margin-bottom: 0.2rem;
}

#action-panel .stamp-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stamp-approve,
.stamp-deny,
.stamp-suspect {
  padding: 0.8rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  border-radius: 4px;
  border: 2px solid;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
}

.stamp-approve {
  background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
  border-color: #1e8449;
  color: #fff;
  box-shadow: 0 3px 0 #1a7a40, 0 4px 8px rgba(0,0,0,0.4);
}

.stamp-approve:hover {
  background: linear-gradient(180deg, #3ddb80 0%, #2ecc71 100%);
  transform: translateY(-1px);
}

.stamp-approve:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1a7a40;
}

.stamp-deny {
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  border-color: #96281b;
  color: #fff;
  box-shadow: 0 3px 0 #8b2018, 0 4px 8px rgba(0,0,0,0.4);
}

.stamp-deny:hover {
  background: linear-gradient(180deg, #f05a4a 0%, #e74c3c 100%);
  transform: translateY(-1px);
}

.stamp-deny:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #8b2018;
}

.stamp-suspect {
  background: linear-gradient(180deg, #f5b041 0%, #f39c12 100%);
  border-color: #d68910;
  color: var(--ink-black);
  box-shadow: 0 3px 0 #b7770a, 0 4px 8px rgba(0,0,0,0.4);
}

.stamp-suspect:hover {
  background: linear-gradient(180deg, #f7c04e 0%, #f5b041 100%);
  transform: translateY(-1px);
}

.stamp-suspect:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b7770a;
}

#action-panel .phone-btn {
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: var(--bg-light);
  border: 1px solid var(--brass);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

#action-panel .phone-btn:hover {
  background: var(--wood-medium);
  border-color: var(--brass-light);
}

/* ============================================
   Documents (Aged Paper)
   ============================================ */
.document {
  background:
    /* Coffee stain */
    radial-gradient(ellipse at 80% 20%, rgba(139, 90, 43, 0.15) 0%, transparent 50%),
    /* Age spots */
    radial-gradient(ellipse at 20% 70%, rgba(120, 80, 30, 0.1) 0%, transparent 40%),
    /* Paper grain */
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.01) 2px,
      rgba(0,0,0,0.01) 4px
    ),
    /* Base paper */
    linear-gradient(170deg, var(--paper-old) 0%, var(--paper-dark) 100%);
  color: var(--ink-black);
  border: 1px solid var(--paper-dark);
  border-radius: 2px;
  padding: 1rem;
  position: relative;
  box-shadow:
    2px 2px 6px rgba(0, 0, 0, 0.3),
    inset 0 0 30px rgba(0, 0, 0, 0.05);
  min-width: 200px;
  max-width: 320px;
  font-size: 0.85rem;
  line-height: 1.6;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.document:hover {
  transform: translateY(-2px) rotate(0.5deg);
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.4);
}

/* Torn edge effect */
.document::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 3px;
  background:
    linear-gradient(90deg,
      transparent 0%, var(--paper-old) 5%, transparent 10%,
      var(--paper-old) 15%, transparent 20%, var(--paper-old) 30%,
      transparent 35%, var(--paper-old) 45%, transparent 50%,
      var(--paper-old) 55%, transparent 65%, var(--paper-old) 70%,
      transparent 80%, var(--paper-old) 85%, transparent 90%,
      var(--paper-old) 95%, transparent 100%
    );
}

.doc-header {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-black);
  border-bottom: 2px solid var(--ink-black);
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
  letter-spacing: 0.2em;
}

.doc-field {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
}

.doc-field .field-label {
  color: rgba(26, 16, 8, 0.6);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.doc-field .field-value {
  font-weight: 600;
  text-align: right;
  color: var(--ink-black);
}

.doc-photo {
  width: 70px;
  height: 85px;
  background: var(--bg-light);
  border: 2px solid var(--ink-black);
  margin: 0.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.doc-photo::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.doc-stamp {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  transform: rotate(-15deg);
  opacity: 0.8;
  padding: 0.2rem 0.6rem;
  border: 3px solid;
  border-radius: 4px;
  pointer-events: none;
}

.doc-stamp.stamp-approved {
  color: var(--success);
  border-color: var(--success);
  top: 30%;
  right: 5%;
}

.doc-stamp.stamp-denied {
  color: var(--danger);
  border-color: var(--danger);
  top: 30%;
  right: 5%;
}

.doc-stamp.stamp-suspicious {
  color: var(--warning);
  border-color: var(--warning);
  top: 30%;
  right: 5%;
}

/* ============================================
   Dialogue Messages
   ============================================ */
.dialogue-msg {
  max-width: 80%;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
  position: relative;
  word-wrap: break-word;
}

.msg-visitor {
  align-self: flex-start;
  background: var(--bg-light);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--wood-medium);
}

.msg-visitor::before {
  content: '';
  position: absolute;
  left: -6px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-right: 6px solid var(--bg-light);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.msg-player {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--wood-medium), var(--wood-dark));
  color: var(--text-primary);
  border-bottom-right-radius: 2px;
  border: 1px solid var(--brass);
}

.msg-player::before {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-left: 6px solid var(--wood-medium);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.msg-system {
  align-self: center;
  background: transparent;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border: none;
}

.msg-phone {
  align-self: center;
  background: rgba(240, 192, 64, 0.1);
  color: var(--text-accent);
  border: 1px dashed var(--brass);
  font-size: 0.8rem;
}

/* ============================================
   Question Buttons
   ============================================ */
.question-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg-medium);
  border: 1px solid var(--wood-medium);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.question-btn:hover {
  background: var(--bg-light);
  border-color: var(--brass);
  color: var(--text-accent);
  padding-left: 0.8rem;
}

.question-btn:active {
  background: var(--wood-dark);
}

.question-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   Flaw Highlight
   ============================================ */
.flaw-highlight {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
  border-radius: 2px;
  animation: pulse 1s ease infinite;
  position: relative;
}

.flaw-highlight::after {
  content: '⚠';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 0.7rem;
  background: var(--danger);
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================
   #phone-overlay
   ============================================ */
#phone-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

#phone-overlay.active {
  display: flex;
}

#phone-overlay .phone-content {
  background:
    linear-gradient(145deg, var(--wood-dark) 0%, var(--bg-dark) 100%);
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 1.5rem;
  width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

#phone-overlay .phone-header {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-accent);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--brass);
  letter-spacing: 0.15em;
}

#phone-overlay .phone-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#phone-overlay .phone-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ============================================
   #results-screen
   ============================================ */
#results-screen {
  background: rgba(0, 0, 0, 0.85);
  justify-content: center;
  align-items: center;
  z-index: 40;
}

#results-screen .results-content {
  background:
    linear-gradient(145deg, var(--bg-medium) 0%, var(--bg-dark) 100%);
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  text-align: center;
  min-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.4s ease;
}

#results-screen .results-title {
  font-size: 1.8rem;
  color: var(--text-accent);
  letter-spacing: 0.3em;
  margin-bottom: 1.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#results-screen .results-grade {
  font-size: 4rem;
  font-weight: 900;
  color: var(--text-accent);
  text-shadow:
    0 0 20px rgba(240, 192, 64, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.6);
  margin-bottom: 1rem;
}

#results-screen .results-grade.grade-s { color: #ffd700; }
#results-screen .results-grade.grade-a { color: var(--success); }
#results-screen .results-grade.grade-b { color: var(--primary); }
#results-screen .results-grade.grade-c { color: var(--warning); }
#results-screen .results-grade.grade-f { color: var(--danger); }

#results-screen .results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

#results-screen .stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: var(--bg-light);
  border-radius: 3px;
  font-size: 0.85rem;
}

#results-screen .stat-item .stat-label {
  color: var(--text-secondary);
}

#results-screen .stat-item .stat-value {
  color: var(--text-accent);
  font-weight: 700;
}

#results-screen .results-buttons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ============================================
   #gameover-screen
   ============================================ */
#gameover-screen {
  background: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
  z-index: 40;
}

#gameover-screen .gameover-content {
  text-align: center;
  animation: fadeIn 0.6s ease;
}

#gameover-screen .gameover-title {
  font-size: 3rem;
  color: var(--danger);
  letter-spacing: 0.4em;
  margin-bottom: 0.5rem;
  text-shadow:
    0 0 30px rgba(192, 57, 43, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.8);
}

#gameover-screen .gameover-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

#gameover-screen .gameover-score {
  font-size: 1.4rem;
  color: var(--text-accent);
  margin-bottom: 2rem;
}

#gameover-screen .gameover-buttons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

/* ============================================
   Modal Overlay
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 60;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background:
    linear-gradient(145deg, var(--bg-medium) 0%, var(--bg-dark) 100%);
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease;
}

.modal-content h2 {
  font-size: 1.3rem;
  color: var(--text-accent);
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--brass);
}

.modal-content p {
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  line-height: 1.7;
}

.modal-content .modal-buttons {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

/* ============================================
   Notifications (Toast)
   ============================================ */
.notification {
  position: fixed;
  top: 60px;
  right: 1rem;
  padding: 0.7rem 1.2rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #fff;
  z-index: 70;
  animation: slideDown 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  max-width: 320px;
  border-left: 4px solid;
}

.notif-success {
  background: rgba(39, 174, 96, 0.9);
  border-left-color: #1e8449;
}

.notif-error {
  background: rgba(192, 57, 43, 0.9);
  border-left-color: #96281b;
}

.notif-warning {
  background: rgba(243, 156, 18, 0.9);
  border-left-color: #d68910;
  color: var(--ink-black);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--brass);
  background:
    linear-gradient(180deg,
      var(--wood-light) 0%,
      var(--wood-medium) 40%,
      var(--wood-dark) 100%
    );
  color: var(--text-primary);
  box-shadow:
    0 2px 0 var(--wood-dark),
    0 3px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn:hover {
  background:
    linear-gradient(180deg,
      #8a6a4a 0%,
      var(--wood-light) 40%,
      var(--wood-medium) 100%
    );
  border-color: var(--brass-light);
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 var(--wood-dark),
    0 5px 10px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 var(--wood-dark),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background:
    linear-gradient(180deg, var(--brass-light) 0%, var(--brass) 50%, #8a6508 100%);
  color: var(--ink-black);
  border-color: #8a6508;
  box-shadow:
    0 2px 0 #6b4f06,
    0 3px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background:
    linear-gradient(180deg, #e0bc55 0%, var(--brass-light) 50%, var(--brass) 100%);
}

.btn-danger {
  background:
    linear-gradient(180deg, #e74c3c 0%, var(--danger) 50%, #96281b 100%);
  color: #fff;
  border-color: #96281b;
  box-shadow:
    0 2px 0 #7a2015,
    0 3px 6px rgba(0, 0, 0, 0.3);
}

.btn-danger:hover {
  background:
    linear-gradient(180deg, #f05a4a 0%, #e74c3c 50%, var(--danger) 100%);
}

.btn-success {
  background:
    linear-gradient(180deg, #2ecc71 0%, var(--success) 50%, #1e8449 100%);
  color: #fff;
  border-color: #1e8449;
  box-shadow:
    0 2px 0 #176b3a,
    0 3px 6px rgba(0, 0, 0, 0.3);
}

.btn-success:hover {
  background:
    linear-gradient(180deg, #3ddb80 0%, #2ecc71 50%, var(--success) 100%);
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes stampSlam {
  0% { transform: scale(3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(-15deg); opacity: 1; }
  80% { transform: scale(1.05) rotate(-15deg); }
  100% { transform: scale(1) rotate(-15deg); opacity: 0.8; }
}

@keyframes typewriter-cursor {
  0%, 100% { border-right-color: var(--text-primary); }
  50% { border-right-color: transparent; }
}

/* ============================================
   Visitor Transitions
   ============================================ */
.visitor-enter {
  animation: visitorEnter 0.5s ease forwards;
}

.visitor-exit {
  animation: visitorExit 0.4s ease forwards;
}

@keyframes visitorEnter {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes visitorExit {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--wood-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--wood-light);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  #game-screen .game-layout {
    grid-template-columns: 180px 1fr 180px;
  }

  .portrait-frame {
    width: 110px;
    height: 110px;
  }

  #menu-screen .menu-title {
    font-size: 2.8rem;
    letter-spacing: 0.3em;
  }
}

@media (max-width: 700px) {
  #game-screen .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  #visitor-panel {
    flex-direction: row;
    border-right: none;
    border-bottom: 2px solid var(--wood-medium);
    padding: 0.5rem;
  }

  #action-panel {
    flex-direction: row;
    flex-wrap: wrap;
    border-left: none;
    border-top: 2px solid var(--wood-medium);
    padding: 0.5rem;
  }

  #action-panel .stamp-buttons {
    flex-direction: row;
  }
}
