:root {
  --wine: #6b2737;
  --slate: #2e5266;
  --parchment: #f2e9e4;
  --panel: rgba(18, 16, 20, 0.82);
  --panel-border: rgba(255, 255, 255, 0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* The [hidden] attribute must win over our display rules on #app/.login-screen/etc. */
[hidden] { display: none !important; }

/* ---- Login gate ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 28%, rgba(107,39,55,.45), transparent 60%),
    linear-gradient(160deg, #14111a 0%, #0b0b0e 70%);
}
.login-card {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 38px 34px 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); backdrop-filter: blur(6px);
}
.login-brand { font-size: 2rem; font-weight: 800; letter-spacing: .5px; color: #e9c87a; }
.login-tag { font-size: .95rem; color: #cbb88a; margin-top: 4px; }
.login-blurb { font-size: .9rem; opacity: .8; margin: 18px 0 24px; line-height: 1.5; }
.login-buttons { display: flex; flex-direction: column; gap: 11px; }
.login-btn {
  width: 100%; padding: 13px 16px; font-size: .98rem; font-weight: 600;
  border-radius: 10px; cursor: pointer; border: 1px solid rgba(255,255,255,.16);
  color: #f2e9e4; background: rgba(255,255,255,.06); transition: background .15s, transform .1s;
}
.login-btn:hover { transform: translateY(-1px); }
.login-primary { background: var(--wine); border-color: transparent; color: #fff; }
.login-primary:hover { background: #843044; }
.login-ms:hover, .login-google:hover { background: rgba(255,255,255,.14); }
.login-btn:disabled { opacity: .45; cursor: not-allowed; }
.login-btn:disabled:hover { transform: none; background: rgba(255,255,255,.06); }
.soon {
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  vertical-align: middle; margin-left: 6px; padding: 2px 6px; border-radius: 8px;
  background: rgba(233,200,122,.2); color: #e9c87a;
}
.login-status { min-height: 18px; font-size: .82rem; color: #ffb3a7; margin-top: 14px; }
.login-fine { font-size: .72rem; opacity: .55; margin-top: 18px; line-height: 1.5; }

/* ---- Signed-in user chip (topbar) ---- */
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.user-name { font-size: .82rem; color: #e6f0f5; opacity: .9; }
.signout-btn {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15);
  color: #e6f0f5; font-size: .76rem; padding: 5px 10px; border-radius: 14px; cursor: pointer;
}
.signout-btn:hover { background: rgba(255,255,255,.14); }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--parchment);
  background: #0b0b0e;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;   /* topbar · main · composer */
}

/* ---- Top status bar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  background: #15131a;
  border-bottom: 1px solid var(--panel-border);
}
.brand { font-weight: 700; letter-spacing: .5px; font-size: 1.05rem; color: #e9c87a; }
.world { font-size: .85rem; color: #cbb88a; opacity: .9; margin-left: 14px; }
.status { font-size: .8rem; opacity: .65; margin-left: auto; }
.icon-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; }
.invite-btn {
  background: rgba(46, 82, 102, 0.6); border: 1px solid rgba(255,255,255,.15); color: #e6f0f5;
  font-size: .82rem; padding: 6px 12px; border-radius: 16px; cursor: pointer;
}
.invite-btn:hover { background: rgba(46, 82, 102, 0.95); }

/* ---- Main: stage (scene + narration) | character panel ---- */
.main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}
.stage {
  display: grid;
  grid-template-rows: 1fr auto;   /* scene image · narration box */
  gap: 12px;
  min-height: 0;
}

/* Scene image — single, centered, framed, never tiled (object-fit covers, transform does Ken Burns) */
.scene-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  background: #000;
  min-height: 0;
}
.scene-img {
  width: 100%; height: 100%;
  object-fit: cover;            /* fills the frame, no repeat, keeps aspect */
  display: block;
  animation: kenburns 45s ease-in-out infinite alternate;
}
@keyframes kenburns {
  from { transform: scale(1.03); }
  to   { transform: scale(1.10); }
}

/* Narration box — readable, below the image, never covering it */
.narration {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px;
  max-height: 30vh;
  display: flex; flex-direction: column;
  backdrop-filter: blur(3px);
}
.speaker {
  font-weight: 700; font-size: .8rem; letter-spacing: 1px; text-transform: uppercase;
  color: #e9c87a; margin-bottom: 8px; flex: 0 0 auto;
}
.log { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.entry { line-height: 1.55; }
.entry.gm { font-size: 1.05rem; }
.entry.player { color: #ffe9b0; font-style: italic; }
.entry.dice {
  font-size: .85rem; background: rgba(0,0,0,.35);
  border-left: 3px solid var(--wine); padding: 5px 10px; border-radius: 4px;
}
.entry.prompt { color: #bcd6ff; font-weight: 600; }

/* Quick-pick option chips (adventure type, suggestions) */
.options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: rgba(107, 39, 55, 0.55);
  border: 1px solid rgba(233, 200, 122, 0.35);
  color: #f2e9e4; font-size: .9rem;
  padding: 8px 14px; border-radius: 20px; cursor: pointer;
  transition: background .15s, transform .1s;
}
.chip:hover { background: rgba(107, 39, 55, 0.9); transform: translateY(-1px); }

/* ---- Character panel (right) ---- */
.party { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
}
.portrait {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  background: linear-gradient(135deg, #2a2330, #15131a);
}
.portrait-ph {
  width: 100%; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 3rem; font-weight: 700; color: #6b5a3a;
  background: radial-gradient(circle at 50% 35%, #2a2330, #121016);
}
.card-body { padding: 10px 12px 12px; }
.char-name { font-weight: 700; font-size: 1.05rem; }
.char-sub { font-size: .78rem; opacity: .7; margin-bottom: 8px; }
.stat-row { display: flex; justify-content: space-between; font-size: .82rem; margin: 3px 0; }
.hpbar { height: 9px; border-radius: 5px; background: #3a1d22; overflow: hidden; margin: 4px 0 8px; }
.hpbar > span { display: block; height: 100%; background: linear-gradient(90deg, #c0392b, #e74c3c); transition: width .4s; }
.conditions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cond { font-size: .7rem; background: #5a2230; color: #ffd9d9; padding: 2px 7px; border-radius: 10px; }

/* ---- Composer ---- */
.composer { display: flex; gap: 10px; align-items: center; padding: 12px 14px 16px; }
.input {
  flex: 1; padding: 13px 16px; font-size: 1rem; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.5); color: #fff;
}
.input:focus { outline: 2px solid var(--slate); }
.mic, .send { padding: 13px 18px; font-size: 1rem; border-radius: 10px; cursor: pointer; border: none; }
.mic { background: rgba(0,0,0,.5); }
.mic.recording { background: var(--wine); animation: pulse 1s infinite; }
.send { background: var(--wine); color: #fff; font-weight: 600; }
@keyframes pulse { 50% { opacity: .6; } }

/* ---- Mobile: stack panel under the stage ---- */
@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; }
  .party { flex-direction: row; overflow-x: auto; }
  .card { min-width: 200px; }
  .narration { max-height: 26vh; }
}
