/* ============================================================
   MaddiesCraft — Direction C "Achievement Unlocked"
   Game-UI energy: dark plum chrome, hot pink primary,
   gold achievement accents.
   ============================================================ */

:root {
  --pink:      #ff5d8f;
  --pink-deep: #c2336a;
  --pink-soft: #ffb8d0;
  --bg-deep:   #1a0e16;
  --bg-panel:  #2a1422;
  --bg-panel2: #3a1c30;
  --cream:     #f6e9d7;
  --gold:      #ffcc44;
  --gold-dim:  #a87a14;
  --green:     #7ec85a;
  --divider:   #52273f;

  --font-head: 'Press Start 2P', 'Pixelify Sans', system-ui, sans-serif;
  --font-mono: 'VT323', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-deep);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(255, 93, 143, 0.15), transparent 50%),
    radial-gradient(circle at 100% 30%, rgba(255, 204, 68, 0.06), transparent 35%),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(255, 255, 255, 0.02) 23px 24px);
  color: var(--cream);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

a { color: inherit; }

.shell {
  width: 100%;
  max-width: 720px;
  padding: 20px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* --- top status bar ---------------------------------------- */
.statusbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--divider);
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.statusbar .brand { color: var(--pink); font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; }
.statusbar .save { color: var(--cream); opacity: 0.6; text-align: center; }
.statusbar .online { color: var(--green); }
.statusbar .online::before { content: '● '; }

/* --- nav --------------------------------------------------- */
.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a {
  background: var(--bg-panel);
  border: 1px solid var(--divider);
  padding: 8px 12px;
  font-family: var(--font-head);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--cream);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  background: var(--bg-panel2);
  color: var(--gold);
  border-color: var(--gold);
}

/* --- crumb bar (sub-pages) --------------------------------- */
.crumb {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
}
.crumb a { color: var(--gold); text-decoration: none; letter-spacing: 1px; }
.crumb .file { color: var(--cream); opacity: 0.5; }

/* --- game panel -------------------------------------------- */
.panel {
  position: relative;
  background: var(--bg-panel);
  border: 2px solid var(--bg-panel2);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.06), 0 4px 0 0 var(--bg-deep);
  padding: 18px;
}
.panel--gold     { --pin: var(--gold); }
.panel--pink     { --pin: var(--pink); }
.panel--cream    { --pin: var(--cream); }
.panel::before, .panel::after,
.panel > .pin-bl, .panel > .pin-br {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  background: var(--pin, var(--pink));
}
.panel::before { top: -2px; left: -2px; }
.panel::after  { top: -2px; right: -2px; }
.panel > .pin-bl { bottom: -2px; left: -2px; }
.panel > .pin-br { bottom: -2px; right: -2px; }

.panel--inner { background: var(--bg-panel2); }

/* --- hero / quest announce --------------------------------- */
.quest-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 14px;
  color: var(--pink); letter-spacing: 1px;
  margin-bottom: 12px;
}
.quest-tag::before {
  content: '';
  width: 9px; height: 9px;
  background: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 93, 143, 0.25);
}

h1.hero {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.3;
  margin: 0;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--bg-deep);
}
h1.hero .accent { color: var(--pink); }

.hero-body {
  font-size: 14px;
  line-height: 1.6;
  margin-top: 14px;
  color: rgba(246, 233, 215, 0.85);
}

/* --- progress meter ---------------------------------------- */
.meter {
  margin-top: 18px;
}
.meter-label {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 14px;
  color: var(--gold); letter-spacing: 1px;
  margin-bottom: 6px;
}
.meter-track {
  height: 14px;
  background: var(--bg-deep);
  border: 1px solid var(--gold);
  display: flex;
}
.meter-fill { background: var(--pink); border-right: 1px solid var(--gold); }
.meter-tick { background: var(--gold); width: 2%; }

/* --- buttons ----------------------------------------------- */
.btn-row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 auto; min-width: 130px; }

.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  padding: 14px 14px;
  font-family: var(--font-head);
  font-size: 10px;
  letter-spacing: 1.2px;
  border: 2px solid var(--cream);
}
.btn--primary { background: var(--pink); color: var(--bg-deep); }
.btn--ghost   { background: transparent; color: var(--gold); border-color: var(--gold); }
.btn--small   { padding: 10px 12px; font-size: 9px; }

/* --- player card ------------------------------------------- */
.player-card { display: flex; align-items: center; gap: 14px; }
.player-pfp {
  width: 78px; height: 78px; flex-shrink: 0;
  background: var(--bg-deep);
  border: 2px solid var(--gold);
  padding: 2px;
}
.player-pfp img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-meta .label { font-family: var(--font-mono); font-size: 13px; color: var(--gold); letter-spacing: 1px; }
.player-meta .name { font-family: var(--font-head); font-size: 14px; color: var(--cream); margin-top: 6px; }
.player-meta .quote { font-family: var(--font-mono); font-size: 14px; color: var(--pink-soft); margin-top: 6px; }

.player-stats {
  margin-top: 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  border-top: 1px solid var(--divider); padding-top: 12px;
}
.player-stats .stat .lbl { font-family: var(--font-mono); font-size: 12px; color: var(--cream); opacity: 0.6; letter-spacing: 1px; }
.player-stats .stat .val { font-family: var(--font-head); font-size: 14px; color: var(--gold); margin-top: 4px; }

/* --- section heading --------------------------------------- */
.section-h {
  font-family: var(--font-head);
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 1.2px;
  margin: 0 0 10px;
}

/* --- achievement block ------------------------------------- */
.achv {
  background: var(--bg-panel);
  border: 2px solid var(--gold);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
}
.achv .icon {
  width: 30px; height: 30px;
  background: var(--bg-deep);
  border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-size: 12px; color: var(--gold);
}
.achv .body .tag { font-family: var(--font-mono); font-size: 13px; color: var(--gold); letter-spacing: 1px; }
.achv .body .ttl { font-family: var(--font-head); font-size: 10px; color: var(--cream); margin-top: 5px; line-height: 1.2; }
.achv .body .sub { font-family: var(--font-mono); font-size: 13px; color: var(--pink-soft); opacity: 0.85; margin-top: 5px; }
.achv .status { font-family: var(--font-mono); font-size: 13px; letter-spacing: 1px; }
.achv .status.done   { color: var(--green); }
.achv .status.live   { color: var(--pink); }
.achv .status.locked { color: var(--gold-dim); }

.achv--live   { border-color: var(--pink); }
.achv--live   .icon { border-color: var(--pink); color: var(--pink); }
.achv--live   .tag  { color: var(--pink); }
.achv--locked { border-color: var(--gold-dim); opacity: 0.85; }
.achv--locked .icon { border-color: var(--gold-dim); color: var(--gold-dim); }
.achv--locked .tag  { color: var(--gold-dim); }

.achv-list { display: flex; flex-direction: column; gap: 6px; }

/* clickable achievement — links to that episode's replay */
a.achv--link { text-decoration: none; color: inherit; cursor: pointer; transition: border-color .15s ease; }
a.achv--link:hover { border-color: var(--pink); }
a.achv--link:hover .ttl { color: var(--pink); }
.achv .body .watch { font-family: var(--font-mono); font-size: 13px; color: var(--pink); letter-spacing: 1px; margin-top: 6px; }

/* --- quick menu (links grid) ------------------------------- */
.quickmenu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.quickmenu .item {
  background: var(--bg-panel);
  border: 1px solid var(--divider);
  padding: 14px;
  text-decoration: none;
  display: flex; flex-direction: column; gap: 5px;
  color: var(--cream);
}
.quickmenu .item .lbl { font-family: var(--font-head); font-size: 9px; letter-spacing: 1.2px; }
.quickmenu .item .sub { font-family: var(--font-mono); font-size: 13px; color: var(--pink-soft); opacity: 0.85; }
.quickmenu .item--primary { background: var(--pink); border: 2px solid var(--cream); color: var(--bg-deep); }
.quickmenu .item--primary .sub { color: var(--bg-deep); opacity: 0.7; }

/* --- live banner (twitch live indicator) ------------------- */
.live-banner {
  display: none;
  align-items: center; gap: 10px;
  background: var(--pink);
  color: var(--bg-deep);
  border: 2px solid var(--cream);
  padding: 12px 14px;
}
.live-banner .dot {
  width: 10px; height: 10px; background: var(--bg-deep); border-radius: 50%;
}
.live-banner a {
  color: var(--bg-deep);
  text-decoration: none;
  font-family: var(--font-head);
  font-size: 10px;
  letter-spacing: 1px;
}

/* --- twitch / youtube embed area --------------------------- */
.embed-frame { padding: 4px; }
.embed-frame iframe,
.embed-frame .placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}
.embed-frame .placeholder {
  background: var(--bg-deep);
  border: 2px solid var(--pink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--pink);
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 1px;
}
.embed-frame .placeholder .small { color: var(--pink-soft); opacity: 0.7; font-size: 12px; }

/* While Twitch.Embed is detecting live status, keep its iframe off-screen.
   `.embed-frame iframe` would otherwise size it to a full 16:9 box on top
   of `.placeholder` on streams.html. main.js removes .detecting on live. */
#twitch-embed.detecting iframe {
  position: absolute;
  left: -99999px;
  width: 320px;
  height: 180px;
  aspect-ratio: auto;
}

/* --- map grid (every state) -------------------------------- */
.map-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  padding: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--divider);
}
@media (max-width: 540px) {
  .map-grid { grid-template-columns: repeat(5, 1fr); }
}
.map-grid .cell {
  aspect-ratio: 1 / 1;
  background: var(--bg-deep);
  color: var(--cream);
  border: 1.5px solid var(--divider);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-size: 9px;
  letter-spacing: 0.5px;
  position: relative;
  opacity: 0.55;
}
.map-grid .cell.done {
  background: var(--bg-panel2);
  color: var(--green);
  border-color: var(--green);
  opacity: 1;
}
.map-grid .cell.done::after {
  content: '✓';
  position: absolute; bottom: 2px; right: 4px;
  font-family: var(--font-mono); font-size: 11px; color: var(--green);
}
.map-grid .cell.live {
  background: var(--pink);
  color: var(--bg-deep);
  border-color: var(--cream);
  opacity: 1;
}
.map-grid .cell.live::after {
  content: '';
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px; background: var(--bg-deep);
}

.map-legend {
  display: flex; gap: 16px;
  margin-top: 10px;
  font-family: var(--font-mono); font-size: 13px;
  color: var(--cream); opacity: 0.7;
  flex-wrap: wrap;
}
.map-legend .swatch::before {
  content: '■ '; margin-right: 2px;
}
.map-legend .done   { color: var(--green); }
.map-legend .live   { color: var(--pink); }
.map-legend .locked { color: var(--gold-dim); }

/* --- mini-stats row ---------------------------------------- */
.mini-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 14px;
}
.mini-stats .stat { border-left: 2px solid var(--divider); padding-left: 12px; }
.mini-stats .stat .v { font-family: var(--font-head); font-size: 14px; }
.mini-stats .stat .l { font-family: var(--font-mono); font-size: 12px; color: var(--cream); opacity: 0.6; letter-spacing: 1px; margin-top: 4px; }
.mini-stats .stat--cleared { border-left-color: var(--green); }
.mini-stats .stat--cleared .v { color: var(--green); }
.mini-stats .stat--active  { border-left-color: var(--pink); }
.mini-stats .stat--active  .v { color: var(--pink); }
.mini-stats .stat--locked  { border-left-color: var(--gold-dim); }
.mini-stats .stat--locked  .v { color: var(--gold-dim); }

/* --- schedule list ----------------------------------------- */
.schedule { display: flex; flex-direction: column; gap: 8px; }
.schedule .row {
  background: var(--bg-panel);
  border: 1px solid var(--divider);
  padding: 14px;
  display: grid; grid-template-columns: 56px 1fr auto;
  gap: 14px; align-items: center;
}
.schedule .row.next { background: var(--bg-panel2); border-color: var(--pink); }
.schedule .day {
  background: var(--bg-deep);
  color: var(--gold);
  border: 1.5px solid var(--gold);
  padding: 7px 0; text-align: center;
  font-family: var(--font-head); font-size: 10px;
}
.schedule .row.next .day { color: var(--pink); border-color: var(--pink); }
.schedule .state-line { font-family: var(--font-head); font-size: 11px; color: var(--cream); }
.schedule .meta { font-family: var(--font-mono); font-size: 13px; color: var(--pink-soft); opacity: 0.85; margin-top: 5px; }
.schedule .pin {
  font-family: var(--font-mono); font-size: 13px;
  color: var(--cream); opacity: 0.5; letter-spacing: 1px;
}
.schedule .row.next .pin { color: var(--pink); opacity: 1; }

/* --- objectives list (house rules) ------------------------- */
.objectives {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.objectives li {
  display: flex; align-items: flex-start; gap: 10px;
  font-family: var(--font-body); font-size: 14px; color: var(--cream);
  line-height: 1.5;
}
.objectives li::before {
  content: '▸';
  color: var(--green);
  font-family: var(--font-mono); font-size: 14px;
  flex-shrink: 0;
}

/* --- footer ------------------------------------------------ */
.footer {
  border-top: 1px solid var(--divider);
  padding-top: 14px;
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 13px;
  color: var(--cream); opacity: 0.6;
}

/* --- utilities --------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.h-rule { height: 1px; background: var(--divider); border: 0; margin: 4px 0; }

/* --- responsive nudges ------------------------------------- */
@media (max-width: 480px) {
  h1.hero { font-size: 22px; }
  .quickmenu { grid-template-columns: 1fr; }
  .player-stats { grid-template-columns: repeat(3, 1fr); }
}
