/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #080810;
  --bg2:       #0d0d1a;
  --bg3:       #12121f;
  --border:    #252540;
  --gold:      #c9a84c;
  --gold-dim:  #7a6530;
  --text:      #e0d8c8;
  --text-dim:  #6e6e90;
  --text-faint:#2e2e4e;
  --accent:    #7b5ea7;
  --red:       #e05252;
  --radius:    6px;
  --font-serif:'Noto Serif SC', serif;
  --font-title:'Cinzel', serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── Start Screen ───────────────────────────────────────────────────────── */
#start-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 30%, #1a1040 0%, transparent 60%),
    var(--bg);
}

.start-inner {
  text-align: center;
  max-width: 500px;
  padding: 2rem;
  animation: fadeUp .8s ease both;
}

.start-ornament {
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: .5rem;
  animation: pulse 3s ease infinite;
}

.start-title {
  font-family: var(--font-title);
  font-size: 2.8rem;
  letter-spacing: .18em;
  color: var(--gold);
  text-shadow: 0 0 40px #c9a84c55;
  margin-bottom: .2rem;
}

.start-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: .4em;
  margin-bottom: 2rem;
}

.start-lore {
  color: var(--text-dim);
  line-height: 2;
  margin-bottom: 2rem;
  font-size: .95rem;
}

.start-input-row {
  display: flex;
  gap: .6rem;
  justify-content: center;
  margin-bottom: .8rem;
}

.start-input-row input {
  flex: 1;
  max-width: 280px;
  padding: .7rem 1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
.start-input-row input:focus { border-color: var(--gold); }

.start-input-row button, #start-btn {
  padding: .7rem 1.4rem;
  background: var(--gold);
  color: #1a1208;
  font-family: var(--font-title);
  font-size: .85rem;
  letter-spacing: .1em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
}
.start-input-row button:hover { background: #e0be6a; }
.start-input-row button:active { transform: scale(.97); }

.start-hint { font-size: .78rem; color: var(--text-faint); }

/* ── Game Layout ────────────────────────────────────────────────────────── */
#game-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1.2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-brand {
  font-family: var(--font-title);
  font-size: .9rem;
  letter-spacing: .18em;
  color: var(--gold);
}

.header-civ {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.hciv-name {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--gold);
}

.hciv-meta {
  font-size: .78rem;
  color: var(--text-dim);
}

.hciv-badge {
  font-size: .72rem;
  padding: .15rem .55rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
}

#game-body {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ── Panels ─────────────────────────────────────────────────────────────── */
aside {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem .8rem;
}

#right-panel {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-section { margin-bottom: 1.4rem; }

.panel-title {
  font-family: var(--font-title);
  font-size: .72rem;
  letter-spacing: .2em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: .7rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--text-faint);
}

.empty-msg {
  font-size: .78rem;
  color: var(--text-faint);
  font-style: italic;
}

/* Culture Bars */
.bar-row {
  display: grid;
  grid-template-columns: 34px 1fr 28px;
  align-items: center;
  gap: .4rem;
  margin-bottom: .45rem;
}

.bar-label { font-size: .72rem; color: var(--text-dim); }

.bar-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--text-faint);
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}

.bar-num {
  font-size: .68rem;
  color: var(--text-faint);
  text-align: right;
}

/* Lexicon */
.lex-entry {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .3rem;
  animation: fadeIn .3s ease;
}

.lex-word {
  font-family: var(--font-title);
  font-size: .78rem;
  color: var(--gold);
}

.lex-meaning {
  font-size: .72rem;
  color: var(--text-dim);
}

/* History */
.hist-entry {
  margin-bottom: .45rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--text-faint);
  animation: fadeIn .3s ease;
}

.hist-entry.hist-major .hist-text { color: var(--gold); }

.hist-year {
  display: block;
  font-size: .65rem;
  color: var(--text-faint);
  font-family: var(--font-title);
  letter-spacing: .06em;
  margin-bottom: .1rem;
}

.hist-text {
  font-size: .76rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ── Main Panel ─────────────────────────────────────────────────────────── */
#main-panel {
  overflow-y: auto;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background:
    radial-gradient(ellipse at 50% 0%, #1a1040 0%, transparent 50%),
    var(--bg);
}

/* ── Opening Sequence ───────────────────────────────────────────────────── */
.opening-sequence {
  text-align: center;
  padding: 3rem 1rem;
}

.opening-line {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  opacity: 0;
  animation: openingFade 1s ease forwards;
}

/* ── Naming Moment ──────────────────────────────────────────────────────── */
.naming-moment {
  width: 100%;
  max-width: 680px;
  text-align: center;
  animation: fadeUp .4s ease both;
}

.concept-era {
  font-family: var(--font-title);
  font-size: .72rem;
  letter-spacing: .2em;
  color: var(--text-faint);
  margin-bottom: .6rem;
}

.concept-name {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: var(--gold);
  text-shadow: 0 0 30px #c9a84c44;
  margin-bottom: .8rem;
  letter-spacing: .08em;
}

.concept-desc {
  font-size: .9rem;
  color: var(--text-dim);
  line-height: 1.8;
  max-width: 500px;
  margin: 0 auto 2rem;
}

.word-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
  margin-bottom: 1.2rem;
}

.word-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem .8rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
  color: var(--text);
  font-family: var(--font-serif);
  animation: fadeUp .4s ease both;
  gap: .3rem;
}

.word-btn:hover {
  border-color: var(--gold);
  background: #1a1830;
  transform: translateY(-2px);
}

.word-btn:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
}

.wb-word {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--gold);
  letter-spacing: .1em;
}

.wb-phonetic {
  font-size: .7rem;
  color: var(--text-faint);
  letter-spacing: .05em;
}

.wb-hint {
  font-size: .75rem;
  color: var(--text-dim);
  margin-top: .1rem;
}

/* Custom word input */
.custom-row {
  display: flex;
  gap: .6rem;
  justify-content: center;
  margin-top: .8rem;
}

.custom-row input {
  flex: 1;
  max-width: 300px;
  padding: .6rem .9rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-title);
  font-size: .9rem;
  letter-spacing: .1em;
  outline: none;
  transition: border-color .2s;
}
.custom-row input:focus { border-color: var(--gold); }
.custom-row input::placeholder { font-family: var(--font-serif); font-size: .78rem; letter-spacing: 0; }

.custom-row button, #custom-submit {
  padding: .6rem 1.1rem;
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-title);
  font-size: .78rem;
  letter-spacing: .1em;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.custom-row button:hover { background: #c9a84c18; border-color: var(--gold); }
.custom-row button:disabled { opacity: .4; cursor: default; }

.input-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: .4rem;
  min-height: 1rem;
  opacity: 0;
  transition: opacity .3s;
}

/* Narrative Box */
.narrative-box {
  width: 100%;
  max-width: 580px;
  margin-top: 1.6rem;
  padding: 1rem 1.2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dim);
  border-radius: var(--radius);
  min-height: 60px;
  line-height: 1.8;
}

.narr-word {
  font-family: var(--font-title);
  color: var(--gold);
  margin-right: .5rem;
  font-size: .9rem;
}

.narr-text {
  color: var(--text-dim);
  font-size: .85rem;
}

/* ── Event Moment ───────────────────────────────────────────────────────── */
.event-moment {
  width: 100%;
  max-width: 620px;
  text-align: center;
  animation: fadeUp .5s ease both;
}

.event-deco {
  font-family: var(--font-title);
  font-size: .72rem;
  letter-spacing: .3em;
  color: var(--gold-dim);
  margin-bottom: .8rem;
}

.event-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 1.2rem;
  text-shadow: 0 0 30px #c9a84c55;
}

.event-narrative {
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 2;
  margin-bottom: 2rem;
  padding: 0 .5rem;
}

.choices-label {
  font-size: .75rem;
  letter-spacing: .15em;
  color: var(--text-faint);
  margin-bottom: .8rem;
  font-family: var(--font-title);
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.choice-btn {
  padding: .85rem 1.2rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: .88rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s, background .2s, transform .15s;
  animation: fadeUp .4s ease both;
}

.choice-btn:hover {
  border-color: var(--gold);
  background: #1a1830;
  transform: translateX(4px);
}

.choice-btn:disabled { opacity: .4; cursor: default; transform: none; }

/* Choice Confirmed */
.choice-confirmed {
  text-align: center;
  padding: 3rem 1rem;
  animation: fadeUp .4s ease both;
  position: relative;
}

.choice-text {
  font-size: 1.1rem;
  color: var(--gold);
  font-family: var(--font-title);
}

.ripple-ring {
  width: 80px;
  height: 80px;
  border: 2px solid var(--gold-dim);
  border-radius: 50%;
  margin: 1.5rem auto 0;
  animation: ripple 1.6s ease forwards;
}

/* Loading Dots */
.loading-dots {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin: 1.5rem 0;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-dim);
  animation: dotPulse 1.2s ease infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

/* ── End Game ───────────────────────────────────────────────────────────── */
.end-game {
  text-align: center;
  max-width: 500px;
  padding: 2rem;
  animation: fadeUp .5s ease both;
}

.end-game h2 {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: var(--gold);
  margin: 1rem 0 .5rem;
}

.eg-desc {
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 1.8;
}

.restart-btn {
  margin-top: 2rem;
  padding: .7rem 2rem;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-title);
  font-size: .85rem;
  letter-spacing: .15em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s;
}
.restart-btn:hover { background: #c9a84c18; }

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes openingFade {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

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

@keyframes dotPulse {
  0%, 100% { transform: scale(.6); opacity: .4; }
  50%       { transform: scale(1);  opacity: 1; }
}

@keyframes ripple {
  0%   { transform: scale(1);  opacity: .8; }
  100% { transform: scale(3);  opacity: 0; }
}

.fade-in {
  animation: fadeIn .6s ease both;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 2px; }
