/* Pigs & Boargons — the look of it.
   Dark parchment and lamplight: a table with a game on it, at night. */

:root {
  --ink:   #eef1ff;
  --dim:   #9aa3c4;
  --bg:    #161a28;
  --panel: #1f2438;
  --edge:  #2a3049;
  --line:  #343b57;
  --hot:   #ffb347;
  --blood: #e05a4a;
  --heal:  #6ee7a0;
  --magic: #b76bff;
  --gold:  #ffd76e;
}
* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 30;
  background: var(--hot); color: #201400; padding: .5rem .8rem; border-radius: 0 0 .5rem 0;
}
.skip-link:focus { left: 0; }

/* ---- the bar across the top ---- */
.bar {
  display: flex; align-items: center; gap: .9rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #12162170;
  position: sticky; top: 0; z-index: 8;
  backdrop-filter: blur(6px);
}
.bar h1 { font-size: 1.1rem; margin: 0; letter-spacing: .01em; }
.bar .home { color: var(--dim); text-decoration: none; font-size: .9rem; }
.bar .home:hover { color: var(--ink); }
.bar .tag { margin: 0 0 0 auto; color: var(--dim); font-size: .78rem; }

main { padding: 1rem; }

/* ---- screens ---- */
.screen { display: none; }
.screen.active { display: block; }

.panel {
  max-width: 44rem; margin: 1.2rem auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.3rem 1.5rem;
  box-shadow: 0 18px 50px #0008;
}
.panel.wide { max-width: 58rem; }
.panel h2 { margin: 0 0 .5rem; font-size: 1.5rem; }
.panel h3 { margin: 1.3rem 0 .4rem; font-size: 1rem; color: var(--hot); }
.lede { color: var(--dim); margin: .2rem 0 1rem; }
.hint { color: var(--dim); font-size: .88rem; }
.hint kbd, .lede kbd {
  background: #0e1120; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: .3rem; padding: 0 .35rem; font-size: .82rem; color: var(--ink);
}

.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

.btn {
  background: var(--hot); color: #221500; border: 0;
  border-radius: .7rem; padding: .6rem 1.1rem;
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn.tiny { padding: .35rem .6rem; font-size: .8rem; }
.btn.ghost { background: #2b3250; color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- picking a class ---- */
.classes { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.klass {
  text-align: left; background: #262d46; border: 2px solid transparent;
  border-radius: .9rem; padding: .9rem 1rem; color: var(--ink);
  font: inherit; cursor: pointer;
}
.klass:hover { background: #2d3553; }
.klass.on { border-color: var(--hot); background: #33324a; }
.klass .k-name { font-weight: 800; font-size: 1.1rem; display: flex; gap: .5rem; align-items: center; }
.klass .k-says { color: var(--dim); font-size: .9rem; margin: .3rem 0 .6rem; }
.klass .k-stat { display: flex; gap: .5rem; font-size: .78rem; color: var(--dim); margin-bottom: .5rem; flex-wrap: wrap; }
.klass .k-stat b { color: var(--ink); }
.klass .k-ab { font-size: .82rem; color: var(--dim); margin: .25rem 0; }
.klass .k-ab b { color: var(--hot); }

/* ---- a list of rows, used for quests, the bag and dialogue options ---- */
.ups { display: grid; gap: .55rem; margin: .6rem 0 0; }
.up {
  text-align: left; background: #262d46; border: 2px solid transparent;
  border-radius: .7rem; padding: .6rem .85rem; color: var(--ink); font: inherit;
  cursor: pointer; width: 100%;
}
.up:hover { background: #2d3553; }
.up.on { border-color: var(--hot); }
.up.flat { cursor: default; }
.up.flat:hover { background: #262d46; }
.up:disabled { opacity: .5; cursor: not-allowed; }
.up-t { font-weight: 700; display: flex; gap: .45rem; align-items: baseline; flex-wrap: wrap; }
.up-b { color: var(--dim); font-size: .86rem; margin-top: .15rem; }
.tick { color: var(--heal); }

/* rarity, everywhere it shows */
.r-common    { color: #c3cadf; }
.r-uncommon  { color: #6ee7a0; }
.r-rare      { color: #67aaff; }
.r-epic      { color: #c58bff; }
.r-legendary { color: var(--gold); text-shadow: 0 0 10px #ffd76e55; }

/* ---- talking ---- */
.panel.talk .says {
  background: #141829; border-left: 3px solid var(--hot);
  padding: .8rem 1rem; border-radius: 0 .6rem .6rem 0; margin: .4rem 0 1rem;
}

/* ---- the character sheet ---- */
.sheet { display: grid; gap: .45rem .9rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.sheet div { background: #262d46; border-radius: .6rem; padding: .45rem .7rem; font-size: .9rem; }
.sheet b { color: var(--hot); }

/* ================= the game itself ================= */
.hud {
  max-width: 60rem; margin: 0 auto .5rem;
  display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
}
.hud-left { flex: 1 1 14rem; min-width: 12rem; }
.hud-mid { display: flex; gap: .4rem; flex-wrap: wrap; }
.hud-right { margin-left: auto; display: flex; gap: .4rem; }

.bar-wrap {
  position: relative; height: 1.35rem; background: #10131f;
  border: 1px solid var(--line); border-radius: .5rem; overflow: hidden;
  margin-bottom: .25rem;
}
.bar-wrap.small { height: .8rem; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .18s; }
.bar-fill.hp { background: linear-gradient(90deg, #c0392b, #e05a4a); }
.bar-fill.xp { background: linear-gradient(90deg, #4a6cf5, #67aaff); }
.bar-wrap span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .76rem; font-weight: 700; text-shadow: 0 1px 2px #000a;
}
.chip {
  background: #262d46; border: 1px solid var(--line);
  border-radius: .5rem; padding: .18rem .5rem; font-size: .8rem;
}
.chip.coin { color: var(--gold); }

.stage {
  position: relative;
  width: min(100%, 60rem);
  max-height: calc(100vh - 12rem);
  aspect-ratio: 3 / 2;
  margin: 0 auto;
}
#world {
  display: block; width: 100%; height: 100%;
  background: #0d1020; border: 1px solid var(--line); border-radius: .8rem;
  touch-action: none;
}

/* the three ability buttons under the world, on a keyboard */
.abilities {
  position: absolute; left: 50%; bottom: .6rem; transform: translateX(-50%);
  display: flex; gap: .5rem; pointer-events: none;
}
.ab {
  position: relative; min-width: 5.6rem;
  background: #1a1f33cc; border: 1px solid var(--line); border-radius: .6rem;
  padding: .3rem .5rem; text-align: center; overflow: hidden;
  backdrop-filter: blur(3px);
}
.ab .ab-k { font-size: .7rem; color: var(--hot); font-weight: 800; }
.ab .ab-n { font-size: .74rem; display: block; line-height: 1.2; }
.ab .ab-cd {
  position: absolute; inset: auto 0 0 0; height: 3px; background: var(--hot);
  width: 0%;
}
.ab.ready { border-color: var(--hot); }
.ab.live { border-color: var(--heal); box-shadow: 0 0 14px #6ee7a055 inset; }

.toast, .prompt {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: #0e1120dd; border: 1px solid var(--line);
  border-radius: .6rem; padding: .35rem .8rem; margin: 0;
  font-size: .9rem; text-align: center; max-width: 90%;
  backdrop-filter: blur(3px);
}
.toast { top: .6rem; }
.prompt { bottom: 3.6rem; color: var(--hot); font-weight: 700; }

/* ================= phones ================= */
.touch, .pad, .tbtn, .stick { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.touch { position: absolute; inset: 0; z-index: 4; }
.pad { position: absolute; inset: 0 45% 0 0; }
.stick {
  position: absolute; width: 104px; height: 104px; margin: -52px 0 0 -52px;
  border: 2px solid #ffffff2a; border-radius: 50%; background: #ffffff10;
}
.stick span {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
  margin: -23px 0 0 -23px; border-radius: 50%; background: #ffffff35;
}
.tbtns {
  position: absolute; right: 2.5%; bottom: 5%;
  display: grid; grid-template-columns: repeat(3, auto); gap: .5rem;
  justify-items: center;
}
.tbtn {
  width: 62px; height: 62px; border-radius: 50%;
  background: #1a1f33cc; border: 2px solid #ffffff28; color: var(--ink);
  font: inherit; display: grid; place-content: center; line-height: 1.05;
}
.tbtn b { font-size: 1rem; }
.tbtn i { font-style: normal; font-size: .54rem; letter-spacing: .02em; color: var(--dim); }
.tbtn:active { background: var(--hot); color: #201400; }
.tbtn.cool { opacity: .4; }
.tbtn.hit { border-color: #e05a4a88; grid-column: span 2; width: 100%; border-radius: 2rem; }
.tbtn.talk { border-color: #6ee7a088; }

.turnme {
  position: absolute; inset: auto 0 45% 0; text-align: center; margin: 0;
  color: var(--hot); font-weight: 700; text-shadow: 0 2px 8px #000;
}

/* ---- filling the screen ---- */
body.full { overflow: hidden; }
body.full .bar, body.full .hud, body.full .row, body.full .skip-link { display: none; }
body.full main { padding: 0; }
body.full .stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  max-height: none; aspect-ratio: auto; margin: 0;
}
body.full #world { border: 0; border-radius: 0; }

@media (max-width: 620px) {
  main { padding: .5rem; }
  .bar h1 { font-size: .95rem; }
  .panel { padding: 1rem; border-radius: .8rem; }
  .hud { font-size: .9rem; }
  .tbtn { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
