:root {
  --bg: #14121f;
  --panel: #1e1a2e;
  --panel-edge: #352b4d;
  --ink: #d8cfc0;
  --ink-dim: #8a8198;
  --candle: #d4a04a;
  --card-bg: linear-gradient(160deg, #241f38, #181426);
  --card-edge: #5a4a7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% -10%, #221c36 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  min-height: 100vh;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0.25rem 1rem;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: normal;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--candle);
}

.header-right { display: flex; gap: 1rem; align-items: baseline; }

#streak { color: var(--candle); font-size: 0.9rem; }

#journal-btn,
#install-btn {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
#journal-btn:hover,
#install-btn:hover { color: var(--ink); }
#install-btn { color: var(--candle); }

/* ---------- the table ---------- */
#table {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0 1rem;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.card-space {
  width: 110px;
  height: 176px;
  border-radius: 10px;
  background: url('../assets/cards/web/cardback.webp') center / cover;
  filter: brightness(0.45) saturate(0.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.slot.revealed .card-space { filter: none; }

.slot-label {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.card {
  position: relative;
  width: 110px;
  height: 176px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-edge);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: turn 0.6s ease;
}

.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card.reversed { transform: rotate(180deg); }

@keyframes turn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; }
}
.card.reversed { animation-name: turn-rev; }
@keyframes turn-rev {
  from { opacity: 0; transform: rotate(180deg) translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: rotate(180deg); }
}

.numeral {
  position: absolute;
  top: 0.3rem;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--candle);
  font-size: 0.75rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.card-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.9rem 0.3rem 0.35rem;
  background: linear-gradient(transparent, rgba(10, 8, 18, 0.85));
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* Reversed cards rotate 180°; the overlays rotate back so they stay
   readable. Net child rotation is 0, so gradients/padding paint as
   authored — only the positions swap ends. */
.card.reversed .card-name,
.card.reversed .numeral { transform: rotate(180deg); }
.card.reversed .card-name { bottom: auto; top: 0; }
.card.reversed .numeral { top: auto; bottom: 0.3rem; }

/* ---------- dialogue ---------- */
#dialogue {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-top: auto;
  margin-bottom: 1rem;
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

#speech {
  margin: 0;
  line-height: 1.65;
  font-size: 1.05rem;
  font-style: italic;
}

#choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.choice {
  background: none;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--candle); background: #262038; }

#continue {
  align-self: flex-end;
  margin-top: auto;
  background: none;
  border: none;
  color: var(--candle);
  font-size: 1.2rem;
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.tip-link {
  color: var(--candle);
  font-size: 0.9rem;
  text-decoration: none;
  align-self: center;
  margin-top: 0.5rem;
}
.tip-link:hover { text-decoration: underline; }

.rest-footer {
  text-align: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--panel-edge);
}
.rest-footer .tease {
  margin: 0 0 0.3rem;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-dim);
}
.rest-footer .countdown {
  margin: 0;
  font-size: 0.85rem;
  color: var(--candle);
  letter-spacing: 0.06em;
}

/* ---------- journal ---------- */
#journal {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#journal[hidden] { display: none; }

.journal-inner {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

.journal-inner h2 {
  margin: 0 0 1rem;
  font-weight: normal;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--candle);
}

#journal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 1rem;
  cursor: pointer;
}

.journal-entry {
  border-top: 1px solid var(--panel-edge);
  padding: 0.75rem 0;
}
.journal-entry h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--candle);
  font-weight: normal;
  letter-spacing: 0.15em;
}
.journal-entry p {
  margin: 0.15rem 0;
  font-size: 0.9rem;
  color: var(--ink-dim);
}
.journal-empty { color: var(--ink-dim); font-style: italic; }

/* ---------- dev bar ---------- */
#devbar[hidden] { display: none; }
#devbar {
  position: fixed;
  bottom: 0;
  left: 0;
  background: #000;
  color: #0f0;
  font-family: monospace;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
#devbar button {
  font-family: monospace;
  font-size: 0.8rem;
  cursor: pointer;
}

@media (max-width: 480px) {
  .card-space, .card { width: 88px; height: 141px; }
  .symbol { font-size: 2rem; }
  #dialogue { padding: 1rem; }
}
