:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", Arial, sans-serif;
  color: #fff1d5;
  background: #251712;
  --ink: #291915;
  --cream: #fff1d5;
  --muted: #d8bca1;
  --gold: #f6ba64;
  --line: #72503a;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 260px; }
[hidden] { display: none !important; }

.screen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 250px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: radial-gradient(ellipse at 35% 0%, #45291c, #251712 68%);
}

.masthead, .foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-inline: clamp(16px, 2.8vw, 96px);
}
.masthead { min-height: 76px; padding-block: 10px; border-bottom: 1px solid #a27248; }
.wordmark { flex: 0 0 auto; }
.wordmark-small, .spectator, .round, .result-label, .arena-label {
  font-weight: 800;
  letter-spacing: .16em;
  font-size: .77rem;
}
.wordmark-small { color: var(--gold); display: block; margin-bottom: 1px; }
h1, h2, .round-intro strong, .callout strong {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}
h1 { margin: 0; font-size: clamp(1.2rem, 2.65vw, 2.15rem); line-height: 1; letter-spacing: -.065em; white-space: nowrap; }
h1 em { color: #fa9b53; font-weight: inherit; }
.spectator { position: absolute; left: 50%; transform: translateX(-50%); color: var(--muted); white-space: nowrap; }
.spectator span { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #e49758; box-shadow: 0 0 10px #e4975877; }
.controls { display: flex; gap: 8px; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--cream);
  background: #ffffff0a;
  border: 1px solid #89634a;
  border-radius: 6px;
  padding: 0 12px;
  min-height: 40px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, button[aria-pressed="true"] { background: #66412a; border-color: #e0a068; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .5; cursor: default; }
#sound > span:first-child { font-size: 1.25rem; line-height: .9; }
.pause-icon { width: 10px; height: 12px; border-inline: 3px solid currentColor; }
#pause[aria-pressed="true"] .pause-icon { width: 0; height: 0; border: 0; border-left: 10px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.fullscreen-icon {
  width: 13px;
  height: 13px;
  background: linear-gradient(currentColor,currentColor) left top / 5px 2px,
    linear-gradient(currentColor,currentColor) right top / 5px 2px,
    linear-gradient(currentColor,currentColor) left bottom / 5px 2px,
    linear-gradient(currentColor,currentColor) right bottom / 5px 2px,
    linear-gradient(currentColor,currentColor) left top / 2px 5px,
    linear-gradient(currentColor,currentColor) right top / 2px 5px,
    linear-gradient(currentColor,currentColor) left bottom / 2px 5px,
    linear-gradient(currentColor,currentColor) right bottom / 2px 5px;
  background-repeat: no-repeat;
}

.stage { position: relative; isolation: isolate; overflow: hidden; background: #d68146; }
#arena { display: block; width: 100%; height: 100%; }
.hud {
  position: absolute;
  inset: clamp(12px, 3.6vh, 48px) 0 auto;
  width: min(calc(100% - clamp(24px, 7vw, 240px)), max(1100px, 55vw));
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: clamp(5px, 1.25vw, 22px);
  transition: opacity .4s;
  pointer-events: none;
}
.fighter, .match {
  background: #302018f2;
  border: 1px solid #ffe3aa95;
  box-shadow: 0 4px 0 #502d2488, 0 12px 22px #4c241938;
  border-radius: 8px;
}
.fighter { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 7px 10px; }
.fighter-info { flex: 1; min-width: 0; }
.portrait { width: clamp(36px, 5.5vh, 65px); aspect-ratio: 1; overflow: hidden; flex: 0 0 auto; border-radius: 50%; background: #436c66; border: 1px solid #e7c697; }
.portrait canvas { display: block; width: 100%; height: 100%; }
.turkey .portrait { background: #994a38; }
.fighter-name { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px; font: italic 900 clamp(.97rem, 2.2vh, 1.45rem)/1 Georgia, serif; }
.wins { color: #edc596; font: 800 .78rem/1 "Trebuchet MS", sans-serif; min-width: 1.65em; text-align: center; border-radius: 3px; background: #ffffff15; padding: 4px; }
.health { display: block; height: clamp(7px, 1.25vh, 14px); background: #130e0b; border: 1px solid #ffe0ae55; border-radius: 3px; overflow: hidden; }
.health i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(var(--hp, 1)); transition: transform .27s ease-out; background: linear-gradient(#afd8b7, #6ca08c); }
.turkey { flex-direction: row-reverse; }
.turkey .fighter-name { flex-direction: row-reverse; }
.turkey .health i { transform-origin: right; background: linear-gradient(#ffd48c, #e4844e); }
.health.raging { border-color: #ffcc7a; box-shadow: 0 0 10px #fc865e; }
.health.raging i { background: linear-gradient(#ffe298, #ed704f); }
.match { min-width: 78px; text-align: center; padding: 7px 10px 5px; }
.round { color: var(--gold); font-size: .67rem; white-space: nowrap; }
.timer { font: 900 clamp(1.5rem, 4.5vh, 3rem)/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.stage.ending .hud { opacity: 0; visibility: hidden; }

.round-intro, .callout, .result, .paused {
  position: absolute;
  left: 50%;
  text-align: center;
  pointer-events: none;
}
.round-intro {
  top: 37%;
  transform: translate(-50%, -50%) scale(.92);
  opacity: 0;
  width: max-content;
  max-width: 93%;
  transition: opacity .25s, transform .25s;
  text-shadow: 0 3px #663227, 0 0 14px #442017;
}
.round-intro.active { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.round-intro span, .callout span { display: block; color: #ffe0a0; font-size: .78rem; letter-spacing: .18em; font-weight: 900; }
.round-intro strong { color: #fff3d6; font-size: clamp(2.1rem, 7vw, 5.8rem); font-style: italic; line-height: .99; }
.callout {
  top: clamp(88px, 21%, 250px);
  transform: translate(-50%, -7px) rotate(-2deg);
  opacity: 0;
  width: max-content;
  max-width: 96%;
  padding: 6px 15px 9px;
  border-radius: 6px;
  background: #35241feb;
  box-shadow: 0 3px #602e2560;
  transition: transform .18s, opacity .18s;
}
.callout.active { transform: translate(-50%, 0) rotate(-2deg); opacity: 1; }
.callout span { font-size: .62rem; }
.callout strong { font-style: italic; font-size: clamp(.94rem, 2.2vw, 1.45rem); }
.result {
  top: 6%;
  transform: translateX(-50%);
  width: min(710px, 95%);
  padding: 10px 15px;
  color: #fff4d6;
  text-shadow: 0 2px #49261e, 0 1px 14px #332019;
  animation: arrive .45s ease-out both;
}
.result-label { display: inline-block; padding: 5px 12px; border: 1px solid #ffd899aa; border-radius: 4px; background: #35201be8; color: #ffd188; }
.result h2 { margin: 5px 0 0; font-size: clamp(1.9rem, 5.5vh, 5rem); letter-spacing: -.055em; font-style: italic; line-height: 1; }
.result p { margin: 6px 0 0; font-size: clamp(.83rem, 1.7vh, 1.15rem); font-weight: 800; }
@keyframes arrive { from { opacity: 0; transform: translate(-50%, -8px); } }
.paused { z-index: 2; top: 50%; transform: translate(-50%, -50%); width: 100%; }
.paused span { display: inline-block; background: #291915f5; border: 1px solid #ffd899; border-radius: 6px; padding: 14px 22px; color: #ffe0a0; letter-spacing: .15em; font-weight: 900; }

.foot { min-height: 46px; border-top: 1px solid #a27248; color: var(--muted); }
.arena-label { display: flex; align-items: center; gap: 8px; color: #f8d0a1; white-space: nowrap; }
.arena-label i { width: 8px; height: 8px; background: #f5a35e; transform: rotate(45deg); }
.ticker { text-align: center; font-size: .86rem; }
.keys { white-space: nowrap; font-size: .76rem; }
kbd { color: #ffdcad; font: inherit; font-weight: 800; border: 1px solid #76533d; border-radius: 3px; padding: 1px 5px; margin-left: 6px; }
.screen.idle { cursor: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#playbook { width: auto; min-height: 24px; padding: 2px 8px; font-size: .78rem; }
#guide { width: min(790px, 94vw); max-height: 84dvh; background: #342218; color: var(--cream); border: 1px solid #c38e59; border-radius: 10px; padding: 0 20px 20px; }
#guide::backdrop { background: #20120ccb; }
#guide header { position: sticky; top: 0; background: #342218; display: flex; align-items: center; justify-content: space-between; padding-block: 12px; border-bottom: 1px solid var(--line); }
#guide h2 { margin: 0; font-style: italic; }
#guide button { width: auto; padding-inline: 10px; }
#trick-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(235px, 100%), 1fr)); gap: 0 24px; }
#trick-list h3 { color: var(--gold); }
#trick-list ol { padding-left: 24px; }
#trick-list li { margin-bottom: 12px; min-height: 65px; display: flow-root; }
#trick-list canvas { float: left; width: 100px; height: auto; margin-right: 10px; border-radius: 5px; }
#trick-list small { display: block; font-size: .84rem; color: var(--muted); }

@media (min-height: 1000px) {
  .masthead { min-height: 92px; }
  .foot { min-height: 54px; }
}
@media (max-width: 850px) {
  .spectator, .keys { display: none; }
}
@media (max-width: 550px) {
  .control-label { display: none; }
  .controls { gap: 5px; }
  button { padding: 0; width: 37px; min-height: 35px; }
  .masthead { min-height: 58px; }
  .fighter { gap: 5px; padding: 5px; }
  .fighter-name { margin-bottom: 4px; }
  .portrait { width: 29px; }
  .match { min-width: 56px; padding-inline: 4px; }
  .round { font-size: .58rem; }
  .foot { padding-block: 6px; gap: 4px; flex-direction: column; justify-content: center; }
  .arena-label { font-size: .67rem; }
  .ticker { font-size: .76rem; }
}
@media (max-width: 340px) {
  .portrait { display: none; }
  .masthead { gap: 4px; padding-inline: 8px; }
  .fighter-name { font-size: .89rem; }
}
@media (max-height: 510px) and (min-width: 551px) {
  .masthead { min-height: 49px; padding-block: 4px; }
  .wordmark-small { font-size: .6rem; }
  h1 { font-size: 1.4rem; }
  button { min-height: 32px; }
  .foot { min-height: 32px; }
  .callout { top: 65px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
