@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/press-start-2p-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --gold: #f0d078;
  --gold-deep: #a97828;
  --ink: #1a120c;
  --cream: #f6ead0;
  --blood: #c4483a;
  --moss: #7dce6a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
button, input { font-family: inherit; }
button { cursor: pointer; }
img { image-rendering: pixelated; }

.tv-body {
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 0%, #2a241c, transparent 40%),
    #050505;
  color: var(--cream);
  font-family: "Press Start 2P", monospace;
}

.bezel {
  width: min(1440px, calc(100vw - 24px));
  height: min(900px, calc(100vh - 24px));
  margin: 12px auto;
  padding: 16px 16px 22px;
  border-radius: 28px;
  background: linear-gradient(#3a3a3a, #141414 40%, #0a0a0a);
  box-shadow:
    inset 0 0 0 2px #4a4a4a,
    inset 0 0 0 6px #1a1a1a,
    0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  position: relative;
}

.bezel-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #8a8a8a;
  font-size: 8px;
  letter-spacing: 2px;
  padding: 0 10px 8px;
}

.screen {
  flex: 1;
  min-height: 0;
  background: #07080f;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 320px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.45);
}

.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025),
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  z-index: 6;
}

.board-wrap { position: relative; min-width: 0; min-height: 0; }
#board, #dice { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#dice { z-index: 5; pointer-events: none; }
#labels { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.token-label {
  position: absolute;
  transform: translate(-50%, 8px);
  font-size: 8px;
  color: #f6ead0;
  text-shadow: 0 2px 0 #000, 0 0 6px #000;
  white-space: nowrap;
}
.ribbon {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.pill {
  background: rgba(8, 8, 12, 0.78);
  border: 3px solid #6a5430;
  color: var(--gold);
  padding: 8px 10px;
  font-size: 10px;
  line-height: 1.5;
  max-width: 70%;
}
.side {
  position: relative;
  z-index: 2;
  background: linear-gradient(#16130f, #0e0c0a);
  border-left: 4px solid #3a2c18;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}
.side h1 {
  margin: 0;
  font-size: 14px;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
}
.side .sub { color: #b9a888; font-size: 8px; line-height: 1.6; }
.tune {
  border: 3px solid #5a4324;
  padding: 8px;
  background: #1a140e;
}
.tune .row { display: flex; align-items: center; gap: 8px; }
.tune strong { color: var(--gold); font-size: 12px; min-width: 36px; text-align: center; }
.tune p { margin: 8px 0 0; color: #b9a888; font-size: 8px; line-height: 1.6; }
.step {
  width: 28px;
  height: 28px;
  background: #3a2c18;
  color: var(--gold);
  border: 2px solid #e6c56a;
}
.plaques { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.plaque {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 6px;
  background: #221c14;
  border: 3px solid #4a3a22;
}
.plaque.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 208, 120, 0.35); }
.plaque.dead { opacity: 0.45; }
.plaque canvas { width: 36px; height: 36px; image-rendering: pixelated; background: #120e0a; }
.plaque .name { font-size: 8px; color: var(--cream); }
.plaque .meta { margin-top: 4px; font-size: 7px; color: #d7c39a; line-height: 1.5; }
.log {
  flex: 1;
  min-height: 80px;
  overflow: auto;
  background: #100e0c;
  border: 3px solid #3a3024;
  padding: 8px;
  font-size: 8px;
  line-height: 1.7;
  color: #e6d7b4;
}
.log div + div { margin-top: 8px; }

.lobby {
  position: absolute;
  z-index: 4;
  left: 16px;
  top: 58px;
  width: min(420px, calc(100% - 32px));
  background: rgba(16, 12, 8, 0.92);
  border: 4px solid #e6c56a;
  box-shadow: 0 0 0 4px #5a4320, 8px 10px 0 rgba(0, 0, 0, 0.4);
  padding: 16px;
}
.lobby h2 { margin: 0 0 8px; font-size: 12px; color: var(--gold); }
.lobby p { margin: 0 0 12px; font-size: 8px; line-height: 1.7; color: #e6d7b4; }
.code {
  font-size: 40px;
  letter-spacing: 8px;
  color: #fff6d8;
  text-shadow: 0 4px 0 #000;
  margin: 8px 0;
}
.qr {
  width: 148px;
  height: 148px;
  image-rendering: pixelated;
  background: #f6e7c1;
  border: 4px solid #6a5430;
}
.join-url { margin-top: 8px; font-size: 8px; line-height: 1.6; color: #f0d078; word-break: break-all; }
.roster { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.roster span {
  border: 2px solid #6a5430;
  padding: 6px;
  font-size: 8px;
  color: var(--cream);
}

.btn {
  font-family: "Press Start 2P", monospace;
  border: 3px solid #6a501c;
  background: linear-gradient(#f4d98a, #d7a441);
  color: #2a1a08;
  box-shadow: inset 0 -4px 0 #a97828, 0 3px 0 #3a240c;
  padding: 12px 10px;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.stone { background: linear-gradient(#4a5568, #2c3442); color: var(--cream); border-color: #1c2430; box-shadow: inset 0 -4px 0 #1a2028, 0 3px 0 #0c1016; }
.btn.red { background: linear-gradient(#e15a48, #a33228); color: #fff6f0; border-color: #4a1612; box-shadow: inset 0 -4px 0 #6a221c; }
.btn.green { background: linear-gradient(#8fd48a, #3e8a48); color: #102010; border-color: #1e4a24; }
.btn.ghost { background: transparent; color: #b9a888; border-color: #5a4a30; box-shadow: none; }
.btn.wide { width: 100%; }

.showcase {
  position: absolute;
  z-index: 7;
  right: 18px;
  top: 64px;
  width: min(300px, 46%);
  pointer-events: none;
  animation: cardIn 0.55s cubic-bezier(.2, 1.4, .3, 1) both;
}
.showcase.framed { width: min(280px, 42%); aspect-ratio: 384 / 544; }
.showcase.framed .sheet { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.showcase.framed .sheet-art { position: absolute; left: 16%; top: 20%; width: 68%; height: auto; image-rendering: pixelated; }
.showcase.framed .sheet-title,
.showcase.framed .sheet-power,
.showcase.framed .sheet-honor,
.showcase.framed .sheet-blurb {
  position: absolute;
  color: #ffe482;
  text-align: center;
  text-shadow: 0 2px 0 #000;
}
.showcase.framed .sheet-title { left: 12%; right: 12%; top: 7.5%; font-size: 10px; line-height: 1.4; }
.showcase.framed .sheet-power { left: 8%; bottom: 6.5%; width: 26%; font-size: 14px; }
.showcase.framed .sheet-honor { right: 8%; bottom: 6%; width: 50%; font-size: 9px; line-height: 1.4; }
.showcase.framed .sheet-blurb { left: 12%; right: 12%; bottom: 8%; font-size: 8px; line-height: 1.45; color: #f6ead0; }
.pcard-frame {
  background: #14301f;
  border: 4px solid #e6c56a;
  box-shadow: 0 0 0 4px #6a5018, 0 16px 0 rgba(0, 0, 0, 0.35);
  padding: 10px;
  position: relative;
}
.pcard-frame.merlin { background: #2a1848; }
.pcard-frame.gear { background: #3a2414; }
.pcard-frame.bad { background: #3a1418; }
.pcard-frame.trap { background: #2a2c30; }
.pcard-frame.sword { background: #3a3018; }
.pcard-frame header {
  text-align: center;
  color: var(--gold);
  font-size: 11px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.pcard-frame .art {
  height: 168px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 220, 140, 0.18), transparent 60%);
}
.pcard-frame .art canvas { image-rendering: pixelated; }
.pcard-frame footer {
  display: grid;
  grid-template-columns: 64px 1fr;
  margin-top: 8px;
  border: 3px solid #d6b25e;
  background: #102418;
}
.pcard-frame .power, .pcard-frame .honor {
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  color: var(--gold);
}
.pcard-frame .honor { font-size: 9px; line-height: 1.4; border-left: 3px solid #d6b25e; }
.pcard-frame .blurb { margin: 8px 0 0; font-size: 8px; line-height: 1.6; color: #f6ead0; }
.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ffe9a0;
  box-shadow: 0 0 8px #ffd56a;
  left: 50%;
  top: 40%;
  animation: spark 0.9s ease-out forwards;
}

@keyframes cardIn {
  0% { transform: rotateY(80deg) scale(0.4); filter: brightness(2); }
  100% { transform: none; filter: none; }
}
@keyframes spark {
  to { transform: rotate(var(--a)) translateY(-120px) scale(0.2); opacity: 0; }
}

.win-banner {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  text-align: center;
  padding: 20px;
}
.win-banner strong {
  display: block;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 4px 0 #000;
  line-height: 1.6;
}

.phone-body {
  min-height: 100%;
  color: var(--cream);
  font-family: "Press Start 2P", monospace;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 140, 40, 0.35), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(255, 120, 30, 0.28), transparent 26%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.15) 0 2px, transparent 2px 48px),
    repeating-linear-gradient(#6a4328 0 22px, #4e3018 22px 26px, #7a5130 26px 48px);
}
.phone {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hero-card {
  background: #1a2218;
  border: 4px solid #e6c56a;
  box-shadow: 0 0 0 4px #5a4320, 0 8px 0 rgba(0, 0, 0, 0.35);
  padding: 10px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
}
.hero-card canvas { width: 92px; height: 92px; image-rendering: pixelated; background: #10160f; }
.hero-card .who { font-size: 11px; color: var(--gold); line-height: 1.5; }
.stats { display: flex; gap: 14px; margin-top: 8px; }
.stats div { text-align: center; }
.stats span { display: block; font-size: 8px; color: #d7c39a; }
.stats b { display: block; margin-top: 4px; font-size: 22px; color: #fff6d8; }
.stats i { display: block; margin-top: 4px; font-style: normal; font-size: 8px; color: #8fd48a; }
.track {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.track-row { display: flex; justify-content: space-between; }
.track span {
  font-size: 8px;
  color: #8a7a60;
  text-align: center;
}
.track span.on { color: var(--gold); }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.chips em {
  font-style: normal;
  font-size: 7px;
  border: 2px solid #6a5430;
  padding: 4px;
  color: #f0d078;
}
.banner-line {
  font-size: 9px;
  line-height: 1.6;
  color: #fff1c8;
  background: rgba(12, 8, 6, 0.72);
  border: 3px solid #6a5430;
  padding: 8px;
}
.room-stage { display: grid; justify-items: center; gap: 4px; }
.room-stage canvas { width: min(100%, 340px); height: auto; touch-action: none; }
.room-stage p { margin: 0; font-size: 8px; line-height: 1.6; color: #f6ead0; text-align: center; }
.orient-actions { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .detail { display: block; margin-top: 4px; font-size: 8px; color: inherit; opacity: 0.8; }
.secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.readout {
  min-height: 36px;
  font-size: 8px;
  line-height: 1.6;
  color: #f6ead0;
  background: rgba(20, 12, 8, 0.55);
  padding: 8px;
}
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 168px;
  padding: 28px 8px 0;
}
.fan {
  width: 96px;
  height: 138px;
  margin: 0 -28px;
  padding: 6px;
  transform-origin: 50% 130%;
  border: 3px solid #e6c56a;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.15s ease;
}
.fan canvas { image-rendering: pixelated; }
.fan .label { font-size: 7px; line-height: 1.35; text-align: center; color: #fff6d8; }
.fan.weapon { background: #1d3f78; }
.fan.armor { background: #6a4a2c; }
.fan.potion { background: #7a2430; }
.fan.bomb { background: #2a241c; }
.fan.magic, .fan.quest { background: #4a2c78; }
.fan.trinket { background: #243038; }
.fan.up { z-index: 3; }
.tray {
  margin-top: auto;
  background: rgba(20, 12, 8, 0.88);
  border: 4px solid #6a5430;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  touch-action: none;
  user-select: none;
}
.tray .hint { font-size: 9px; line-height: 1.5; color: var(--gold); }
.tray .hint small { display: block; color: #e6d7b4; font-size: 8px; margin-top: 4px; }
.dice-pair { display: flex; gap: 6px; }
.die {
  width: 54px;
  height: 54px;
  background: #f6f1e4;
  color: #1a120c;
  display: grid;
  place-items: center;
  font-size: 18px;
  border: 3px solid #2a2118;
  box-shadow: 3px 3px 0 #000;
}
.die.dim { opacity: 0.4; }
.die.flung { animation: flung 0.45s ease-in forwards; }
@keyframes flung {
  to { transform: translateY(-180px) rotate(40deg); opacity: 0; }
}
.join {
  margin: auto;
  width: min(420px, 100%);
  background: rgba(16, 12, 8, 0.92);
  border: 4px solid #e6c56a;
  box-shadow: 0 0 0 4px #5a4320;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.join h1 { margin: 0; font-size: 16px; color: var(--gold); line-height: 1.5; }
.join p { margin: 0; font-size: 8px; line-height: 1.7; color: #e6d7b4; }
.join input {
  width: 100%;
  background: #100e0c;
  color: var(--cream);
  border: 3px solid #6a5430;
  padding: 12px;
  font-size: 14px;
  text-transform: uppercase;
}
.err { color: #ffb0a4; font-size: 8px; line-height: 1.6; }
.warn { color: #f0d078; }

@media (max-width: 860px) {
  .bezel { height: auto; min-height: calc(100vh - 24px); }
  .screen { grid-template-columns: 1fr; grid-template-rows: minmax(420px, 62vh) auto; }
  .side { border-left: 0; border-top: 4px solid #3a2c18; max-height: 360px; }
  .showcase { top: 54px; right: 8px; }
}
