:root {
  --ink: #2b2233;
  --paper: #f4ecd8;
  --accent: #e8a33d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: #1b1622;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--paper);
  overflow: hidden;
}
#stage {
  position: relative;
  width: 960px; max-width: 96vw;
  aspect-ratio: 960 / 600; height: auto;
  margin: 16px auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
/* warm vignette for a cozy, low-lit feel (no element overflow) */
#stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 12px;
  box-shadow: inset 0 0 120px rgba(20,14,28,.55);
}

/* mute button */
#mute {
  position: absolute; top: 10px; right: 12px; pointer-events: auto;
  background: rgba(43,34,51,.7); border: 1px solid var(--accent); color: var(--paper);
  border-radius: 8px; width: 34px; height: 30px; cursor: pointer; font-size: 14px;
}

/* touch controls — hidden on devices without touch (shown via media query) */
#touch { position: absolute; inset: 0; pointer-events: none; display: none; }
#touch .dpad {
  position: absolute; left: 16px; bottom: 16px; display: grid;
  grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 6px;
}
#touch .dpad button { pointer-events: auto; }
#touch-e {
  position: absolute; right: 20px; bottom: 28px; pointer-events: auto;
  width: 64px; height: 64px; border-radius: 50%; font-weight: 700; font-size: 18px;
  background: var(--accent); color: #2b2233; border: 0;
}
#touch .actions { position: absolute; right: 18px; bottom: 24px; display: flex; gap: 10px; align-items: flex-end; }
#touch .actions button {
  width: 58px; height: 58px; border-radius: 50%; font-weight: 700; font-size: 20px;
  background: var(--accent); color: #2b2233; border: 0; pointer-events: auto;
}
#touch #touch-r { background: #5fe9ad; }
#touch button {
  background: rgba(43,34,51,.72); color: var(--paper); border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; font-size: 18px;
}
@media (pointer: coarse) { #touch { display: block; } #hint { display: none; } }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 10px 14px;
  pointer-events: none;
  display: flex; flex-direction: column; gap: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
#beat-title { font-size: 18px; font-weight: 700; opacity: .92; }
#beat-line { font-size: 14px; opacity: .8; font-style: italic; max-width: 70%; }
#hint { font-size: 13px; opacity: .85; position: absolute; left: 12px; bottom: 10px; right: auto; max-width: 64%; }

/* persistent brand mark (top-left) — subtle, never in the way */
#brand {
  position: absolute; top: 8px; left: 12px; pointer-events: auto;
  display: flex; align-items: center; gap: 7px; z-index: 5;
  font-family: Georgia, serif; font-weight: 700; color: var(--paper);
  text-shadow: 0 1px 3px rgba(0,0,0,.7); font-size: 15px;
}
#brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
#brand a { color: var(--paper); text-decoration: none; }

/* CTA button on the end banner */
.cta {
  display: inline-block; margin-top: 6px; padding: 11px 20px; border-radius: 9px;
  background: var(--accent); color: #2b2233; font-weight: 700; text-decoration: none;
  font-size: 15px; box-shadow: 0 6px 20px rgba(232,163,61,.4);
}
.cta:hover { filter: brightness(1.05); }
#prompt {
  align-self: center; margin-top: 6px;
  background: rgba(43,34,51,.82);
  border: 1px solid var(--accent);
  padding: 6px 14px; border-radius: 999px; font-size: 14px;
}
#prompt b { color: var(--accent); }

#panel {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,8,14,.55);
  backdrop-filter: blur(2px);
}
.panel-card {
  width: 520px; max-width: 92%;
  background: var(--paper); color: var(--ink);
  border-radius: 14px; padding: 22px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
/* tailoring modules */
.mod { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; margin: 5px 0;
  border-radius: 9px; background: #ece2cd; font-size: 14px; cursor: pointer; }
.mod.on { background: #dfeccd; }
.mod.t { border-left: 3px solid var(--accent); }
.mod em { color: #b5641b; font-style: normal; font-size: 12px; opacity: .8; }
.mod input { margin-top: 2px; }
.sub.now { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; font-size: 13px; font-weight: 600; }
.sub.now span { background: #efe6d2; padding: 4px 8px; border-radius: 7px; }
#submit { margin-top: 12px; }
#submit:disabled { opacity: .5; cursor: not-allowed; }
.panel-card h2 { margin: 0 0 6px; font-family: Georgia, serif; }
#panel-score { font-size: 18px; margin-bottom: 10px; }
#panel-score b { color: #b5641b; }
#reasons { margin: 0 0 16px; padding-left: 18px; line-height: 1.5; font-size: 15px; }
#reasons li { margin: 4px 0; }
#reasons li.truth { list-style: none; margin-left: -18px; font-style: italic; opacity: .85; }

/* honest score panel */
#panel-score b { color: #b5641b; }
.beat-line { font-size: 16px; line-height: 1.45; margin: 4px 0 8px; }
.beat-feel { font-size: 13px; opacity: .8; margin: 0 0 6px; }
.subs { margin: 10px 0; }
.sub { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sub .sk { width: 78px; font-weight: 600; }
.sub .bar { flex: 1; height: 9px; background: #e3d8c4; border-radius: 6px; overflow: hidden; }
.sub .bar i { display: block; height: 100%; }
.sub .sv { width: 26px; text-align: right; font-weight: 700; }
.snote { font-size: 12px; opacity: .75; margin: 1px 0 8px 86px; }
.master { font-size: 12px; opacity: .8; margin: 6px 0 0; }
#close {
  border: 0; cursor: pointer;
  background: var(--accent); color: #2b2233;
  font-weight: 700; padding: 9px 16px; border-radius: 8px;
}
#close:hover { filter: brightness(1.05); }

#boot {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #1b1622; color: #8a7f9c; font-size: 18px;
  transition: opacity .4s ease;
}
#boot.hidden { opacity: 0; pointer-events: none; }
.hidden { display: none !important; }

/* completion banner — same game-key-art vibe as the title screen */
#done {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(100deg, rgba(10,8,14,.88) 0%, rgba(10,8,14,.72) 50%, rgba(10,8,14,.40) 100%);
  backdrop-filter: blur(2px);
}
.done-card {
  width: 460px; max-width: 90%; text-align: center;
  background: linear-gradient(135deg, rgba(61,220,151,.12), rgba(232,163,61,.07));
  color: var(--paper); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 34px 32px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 0 40px rgba(61,220,151,.18);
}
.done-title {
  font-family: Georgia, serif; font-size: 30px; font-weight: 800; line-height: 1.12; margin-bottom: 12px;
  text-shadow: 0 0 24px rgba(61,220,151,.6);
}
.done-card.lose .done-title { text-shadow: 0 0 24px rgba(224,98,90,.6); }
.done-sub { font-size: 15px; line-height: 1.6; opacity: .9; margin-bottom: 20px; }
.cta {
  display: inline-block; text-decoration: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #ffd86b); color: #2b2233;
  font-weight: 800; font-size: 18px; padding: 13px 30px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(232,163,61,.45); transition: transform .12s ease, box-shadow .12s ease;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(232,163,61,.6); }
#done-close, #done-retry {
  border: 0; cursor: pointer; background: rgba(255,255,255,.10); color: var(--paper);
  font-weight: 600; font-size: 14px; padding: 12px 18px; border-radius: 12px;
}
#done-retry { background: linear-gradient(135deg, var(--accent), #ffd86b); color: #2b2233; font-weight: 800; }

/* title / start screen — game key-art: dark left, live arena showing on the right */
.overlay {
  position: absolute; inset: 0; display: flex;
  background: linear-gradient(100deg, rgba(10,8,14,.96) 0%, rgba(10,8,14,.92) 38%, rgba(10,8,14,.45) 62%, rgba(10,8,14,.15) 100%);
}
.title-side {
  width: 540px; max-width: 92%; padding: 40px 46px;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(135deg, rgba(61,220,151,.10), rgba(232,163,61,.06));
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 30px 0 80px rgba(0,0,0,.5);
}
.title-name {
  font-family: Georgia, serif; font-size: 38px; font-weight: 800; line-height: 1.08;
  text-shadow: 0 0 22px rgba(61,220,151,.55), 0 2px 0 rgba(0,0,0,.3);
}
.title-name span { color: var(--accent); text-shadow: 0 0 22px rgba(232,163,61,.6); }
.title-tag {
  font-size: 13px; letter-spacing: .22em; text-transform: uppercase; opacity: .7; margin: 10px 0 18px;
  color: var(--accent);
}
.title-story { font-size: 15px; line-height: 1.6; opacity: .92; margin: 0 0 18px; }
.title-controls {
  text-align: left; font-size: 14px; line-height: 1.8;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px; padding: 12px 18px; margin: 0 0 20px;
}
.title-controls b { color: var(--accent); }
.title-row { display: flex; gap: 14px; align-items: center; }
#title-start {
  border: 0; cursor: pointer; background: linear-gradient(135deg, var(--accent), #ffd86b); color: #2b2233;
  font-weight: 800; font-size: 20px; padding: 14px 34px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(232,163,61,.45); transition: transform .12s ease, box-shadow .12s ease;
}
#title-start:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(232,163,61,.6); }
#title-music {
  border: 0; cursor: pointer; background: rgba(255,255,255,.10); color: var(--paper);
  font-weight: 600; font-size: 14px; padding: 14px 18px; border-radius: 12px;
}
.title-foot { margin-top: 18px; font-size: 12px; opacity: .5; }
.title-stage { flex: 1; }
