:root{
  --bg-deep: #16241f; --bg-deep2: #0e1815;
  --panel: #f4ecd8; --panel-edge: #e2d3ac;
  --ink: #2b2118; --ink-soft: #5a4a37;
  --wheat: #c98a2e; --potato: #7d5a3c;
  --danger: #7a3030; --sage: #4d6b53; --gold: #d9a441;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;min-height:100%;}
body{
  background: radial-gradient(ellipse at top, #23362f 0%, var(--bg-deep) 45%, var(--bg-deep2) 100%);
  font-family:'PT Sans', sans-serif; color: var(--panel); min-height:100vh;
}
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 24px; background: rgba(14,24,21,.9); backdrop-filter: blur(6px);
  border-bottom:1px solid rgba(217,164,65,.2);
}
.brand{ font-family:'Lora', serif; font-style:italic; font-size:19px; color:var(--panel); text-decoration:none; }
.brand span{ color: var(--gold); }
.topbar-right button{
  background:none; border:1px solid rgba(244,236,216,.3); color: rgba(244,236,216,.85);
  padding:7px 14px; border-radius:2px; cursor:pointer; font-family:'PT Sans'; font-size:13px; margin-left:8px;
}
.topbar-right button:hover{ border-color: var(--gold); color: var(--gold); }

.stage{ width:100%; max-width:900px; margin:0 auto; padding:32px 16px 64px; }
.stage.narrow{ max-width:720px; }

.eyebrow{ font-size:12px; letter-spacing:.14em; text-transform:uppercase; color: var(--gold); margin-bottom:14px; display:flex; align-items:center; gap:10px; }
.eyebrow::after{ content:""; flex:1; height:1px; background:linear-gradient(90deg, rgba(217,164,65,.6), transparent); }

.art{ height:210px; border-radius:4px; margin-bottom:18px; position:relative; overflow:hidden; border:1px solid rgba(217,164,65,.25); }
.art svg{ width:100%; height:100%; display:block; }

.card{
  background: var(--panel); color: var(--ink); border-radius:3px; padding:34px 38px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px var(--panel-edge); position:relative;
}
.card::before{ content:""; position:absolute; inset:10px; border:1px solid rgba(43,33,24,.12); pointer-events:none; }
.title-main{ font-family:'Lora', serif; font-size:28px; font-weight:600; line-height:1.25; margin:0 0 18px; color: var(--ink); }
.story-text{ font-family:'Lora', serif; font-size:17px; line-height:1.75; color: var(--ink); white-space:pre-line; }
.story-text + .story-text{ margin-top:14px; }

.choices{ margin-top:28px; display:flex; flex-direction:column; gap:10px; }
.choice-btn{
  text-align:left; font-family:'PT Sans', sans-serif; font-size:15px; background: transparent;
  border:1px solid rgba(43,33,24,.28); color: var(--ink); padding:14px 18px; border-radius:2px;
  cursor:pointer; position:relative; transition: border-color .15s ease, background .15s ease, transform .1s ease; line-height:1.4; width:100%;
}
.choice-btn::before{ content:"❧"; color: var(--wheat); margin-right:10px; font-size:13px; }
.choice-btn:hover{ background: rgba(201,138,46,.09); border-color: var(--wheat); transform: translateX(2px); }
.flag-hint{ font-size:12px; color: var(--ink-soft); margin-top:6px; font-style:italic; }

.continue-btn{
  margin-top:26px; font-family:'PT Sans', sans-serif; font-size:14px; letter-spacing:.06em; text-transform:uppercase;
  background: var(--ink); color: var(--panel); border:none; padding:13px 26px; border-radius:2px; cursor:pointer;
}
.continue-btn:hover{ background:#3a2c1e; }
.continue-btn.secondary{ background:transparent; color:var(--ink); border:1px solid rgba(43,33,24,.3); margin-left:10px; }

.title-screen{ text-align:center; padding:60px 30px; }
.title-screen h1{ font-family:'Lora', serif; font-size:38px; font-style:italic; margin-bottom:8px; }
.title-screen p{ color: var(--ink-soft); font-size:14px; margin-bottom:32px; }

/* auth */
.auth-form{ max-width:340px; margin:0 auto; text-align:left; }
.auth-form label{ display:block; font-size:12px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-soft); margin:14px 0 6px; }
.auth-form input{
  width:100%; padding:11px 12px; border:1px solid rgba(43,33,24,.3); border-radius:2px;
  font-family:'PT Sans'; font-size:15px; background:#fffdf7; color:var(--ink); letter-spacing:1px;
}
.auth-error{ color:var(--danger); font-size:13px; margin-top:10px; min-height:18px; }
.auth-note{ color:var(--ink-soft); font-size:12px; margin-top:14px; font-style:italic; }
.auth-switch{ text-align:center; margin-top:18px; font-size:13px; color:var(--ink-soft); }
.auth-switch a{ color:var(--wheat); cursor:pointer; text-decoration:underline; }

.recap-box{
  background: rgba(217,164,65,.08); border:1px dashed rgba(217,164,65,.4);
  padding:16px 18px; border-radius:2px; margin-top:18px; font-size:14px; color:var(--ink-soft); font-style:italic; display:none;
}
.recap-box.visible{ display:block; }

.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--ink); color:var(--gold); padding:14px 22px; border-radius:3px; font-size:14px;
  box-shadow:0 10px 30px rgba(0,0,0,.5); z-index:50; opacity:0; transition:opacity .3s ease, transform .3s ease;
  pointer-events:none; text-align:center;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-6px); }

.ending-card{ border-top:3px solid var(--gold); }
.gameover-card{ border-top:3px solid var(--danger); }
.ending-title{ font-family:'Lora', serif; font-style:italic; font-size:14px; letter-spacing:.06em; text-transform:uppercase; color: var(--wheat); margin-bottom:6px; }
.gameover-title{ font-family:'Lora', serif; font-style:italic; font-size:14px; letter-spacing:.06em; text-transform:uppercase; color: var(--danger); margin-bottom:6px; }

.summary{ margin-top:28px; padding-top:18px; border-top:1px dashed rgba(43,33,24,.25); }
.summary h3{ font-size:12px; text-transform:uppercase; letter-spacing:.1em; color: var(--ink-soft); margin-bottom:10px; }
.summary ul{ margin:0; padding-left:18px; font-size:14px; color:var(--ink-soft); line-height:1.9;}

.footnote{ text-align:center; font-size:12px; color: rgba(244,236,216,.4); margin-top:22px; }

/* achievements */
.ach-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:20px; }
@media (max-width:560px){ .ach-grid{ grid-template-columns:1fr; } }
.ach-item{ border:1px solid rgba(43,33,24,.2); padding:12px 14px; border-radius:2px; }
.ach-item.locked{ opacity:.35; }
.ach-item .ach-title{ font-family:'Lora', serif; font-weight:600; font-size:14px; }
.ach-item .ach-desc{ font-size:12px; color:var(--ink-soft); margin-top:4px; }
.ach-item .ach-story{ font-size:11px; color:var(--wheat); text-transform:uppercase; letter-spacing:.05em; margin-top:6px; }

/* catalog */
.catalog-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(260px, 1fr)); gap:20px; margin-top:24px; }
.story-tile{
  background: var(--panel); border-radius:4px; overflow:hidden; cursor:pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,.35); transition: transform .15s ease, box-shadow .15s ease;
  display:flex; flex-direction:column;
}
.story-tile:hover{ transform: translateY(-4px); box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.story-tile .tile-art{ height:140px; }
.story-tile .tile-art svg{ width:100%; height:100%; display:block; }
.story-tile .tile-body{ padding:18px 20px 22px; color:var(--ink); flex:1; display:flex; flex-direction:column; }
.story-tile h3{ font-family:'Lora', serif; font-size:19px; margin:0 0 8px; }
.story-tile p{ font-size:13px; color: var(--ink-soft); line-height:1.5; flex:1; }
.tile-progress{ margin-top:12px; font-size:12px; color: var(--wheat); font-weight:bold; }
.tile-cta{ margin-top:14px; font-size:12px; text-transform:uppercase; letter-spacing:.08em; color: var(--ink); border-top:1px solid rgba(43,33,24,.15); padding-top:12px; }

/* profile */
.profile-header{ display:flex; align-items:center; gap:22px; margin-bottom:24px; }
.avatar-wrap{ position:relative; width:96px; height:96px; flex-shrink:0; }
.avatar-img{ width:96px; height:96px; border-radius:50%; object-fit:cover; border:3px solid var(--gold); background:#ddd2b5; }
.avatar-placeholder{
  width:96px; height:96px; border-radius:50%; border:3px solid var(--gold);
  background: var(--sage); color:#fff; display:flex; align-items:center; justify-content:center;
  font-family:'Lora', serif; font-size:36px;
}
.avatar-edit-btn{
  position:absolute; bottom:0; right:0; background:var(--ink); color:var(--gold);
  border:2px solid var(--panel); border-radius:50%; width:30px; height:30px; font-size:14px;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.profile-name{ font-family:'Lora', serif; font-size:26px; font-weight:600; }
.profile-level{
  display:inline-block; margin-top:4px; padding:3px 12px; border-radius:12px;
  background: var(--wheat); color:#fff; font-size:12px; text-transform:uppercase; letter-spacing:.06em;
}
.profile-progressbar{ height:6px; background: rgba(43,33,24,.15); border-radius:3px; margin-top:10px; overflow:hidden; width:220px; }
.profile-progressbar-fill{ height:100%; background: var(--wheat); }

.corner-sig{ position:fixed; top:70px; right:18px; width:56px; height:56px; opacity:0.9; z-index:5; }
@media (max-width:720px){ .corner-sig{ display:none; } }

.music-toggle{
  position:fixed; bottom:24px; right:24px; z-index:30;
  width:48px; height:48px; border-radius:50%; border:1px solid rgba(217,164,65,.4);
  background: rgba(14,24,21,.85); color:var(--gold); font-size:20px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; box-shadow:0 8px 20px rgba(0,0,0,.4);
}
.music-toggle:hover{ border-color: var(--gold); }
.music-toggle.muted{ opacity:0.5; }
