:root {
  color-scheme: light;
  --paper: #f7f0df;
  --panel: #fffdf7;
  --ink: #191919;
  --red: #d82138;
  --yellow: #ffe23b;
  --orange: #ff7137;
  font-family: "Barlow Condensed", Impact, "Arial Narrow", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px;
  background-color: var(--paper);
  background-image: radial-gradient(var(--ink) 0.8px, transparent 0.9px);
  background-size: 14px 14px;
}

body.game-page { padding: 16px; }

button, textarea { font: inherit; }

.app-shell {
  width: min(100%, 1040px);
  min-height: calc(100vh - 56px);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 48px);
  border: 3px solid var(--ink);
  background: var(--panel);
  box-shadow: 10px 10px 0 var(--ink);
}

.game-screen {
  display: grid;
  width: 100%;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-height: 520px;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: clamp(22px, 3vw, 40px);
  margin: 0;
  padding: clamp(22px, 3vw, 40px);
}

.game-sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.game-sidebar .masthead {
  align-items: flex-start;
  flex-direction: column;
  gap: 18px;
}

.game-sidebar .toolbar {
  flex-direction: column;
}

.game-sidebar .toolbar button {
  width: 100%;
}

.game-sidebar .game-status {
  margin: auto 0 0;
}

.game-sidebar .page-footer {
  justify-content: flex-start;
  margin-top: 20px;
  padding-top: 14px;
}

.game-stage {
  min-width: 0;
  min-height: 0;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 4rem;
  font-weight: 900;
  line-height: 0.9;
  text-transform: uppercase;
}

.header-note {
  margin: 0;
  color: var(--red);
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 0.95;
  text-align: right;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 0;
}

button, .button-quiet {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

button:hover:not(:disabled), .button-quiet:hover { background: var(--orange); }
button:active:not(:disabled) { box-shadow: 1px 1px 0 var(--ink); transform: translate(3px, 3px); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid #164ef0; outline-offset: 4px; }

.button-primary { background: var(--red); color: var(--panel); }
.button-primary:hover:not(:disabled) { background: #ad1027; }
.button-quiet { background: var(--panel); }

#game-area {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 3px solid var(--ink);
  background-color: #fff9e8;
  background-image: radial-gradient(#cfc6b3 0.8px, transparent 0.9px);
  background-size: 13px 13px;
  box-shadow: inset 0 0 0 5px var(--panel);
}

.player {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--ink);
  animation: fade-in 500ms ease-out;
  isolation: isolate;
}

.player::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    to top,
    var(--red) 0 var(--damage-level, 0%),
    transparent var(--damage-level, 0%) 100%
  );
  content: "";
}

.emoji { position: relative; font-size: 2.6rem; line-height: 1; }

.player .name {
  position: absolute;
  top: -2.1rem;
  left: 50%;
  z-index: 2;
  max-width: 120px;
  overflow: hidden;
  padding: 1px 5px;
  border: 1px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
}

.player .health {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.player.knocked-out {
  z-index: 3;
  pointer-events: none;
  animation: thrown-out 900ms cubic-bezier(0.2, 0.75, 0.35, 1) forwards;
}

.message {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: min(90%, 700px);
  color: var(--yellow);
  font-size: 6rem;
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  text-transform: uppercase;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 6px 0 var(--ink);
  transform: translate(-50%, -50%) rotate(-4deg);
}

.game-status {
  min-height: 1.6em;
  margin: 16px 0 0;
  font-size: 1.2rem;
  font-weight: 900;
  text-transform: uppercase;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #b9b4a9;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
}

.page-footer p { margin: 0; }
.page-footer a { color: var(--red); }
.page-footer .button-quiet { min-height: 34px; padding: 0 10px; font-size: 0.9rem; box-shadow: 2px 2px 0 var(--ink); }
.game-footer { justify-content: flex-end; }

@media (max-width: 600px) {
  body { padding: 14px; }
  .app-shell { min-height: calc(100vh - 28px); padding: 22px; box-shadow: 6px 6px 0 var(--ink); }
  .masthead { align-items: start; flex-direction: column; }
  h1 { font-size: 3rem; }
  .header-note { text-align: left; }
  #game-area { height: 52vh; min-height: 340px; }
  .message { font-size: 3rem; }
  .page-footer { align-items: start; flex-direction: column; }
  .game-footer { align-items: end; }
}

@media (max-width: 860px) {
  body.game-page { padding: 12px; }
  .game-screen {
    height: auto;
    min-height: calc(100dvh - 24px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(52vh, 1fr);
    gap: 16px;
    padding: 20px;
  }
  .game-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px 16px;
  }
  .game-sidebar .masthead {
    align-items: flex-start;
    flex-direction: row;
    gap: 10px;
    padding: 0;
    border: 0;
  }
  .game-sidebar h1 { font-size: 2.5rem; }
  .game-sidebar .eyebrow { font-size: 0.9rem; }
  .game-sidebar .edit-players {
    min-height: 40px;
    padding: 0 9px;
    font-size: 0.95rem;
  }
  .game-sidebar .toolbar {
    flex-direction: row;
    gap: 10px;
    padding: 0;
  }
  .game-sidebar .toolbar button { width: auto; }
  .game-sidebar .game-status { margin: 0; }
  .game-sidebar .page-footer {
    align-items: center;
    flex-direction: row;
    justify-content: flex-end;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .game-stage { min-height: 52vh; }
  #game-area { height: 100%; min-height: 0; }
}

@media (max-width: 520px) {
  .game-screen { padding: 16px; }
  .game-sidebar { grid-template-columns: minmax(0, 1fr); }
  .game-sidebar .masthead { justify-content: space-between; }
  .game-sidebar h1 { font-size: 2.1rem; }
  .game-sidebar .eyebrow { font-size: 0.8rem; }
  .game-sidebar .toolbar button { flex: 1; padding: 0 9px; font-size: 1rem; }
  .game-sidebar .game-status { grid-row: 3; }
  .game-sidebar .page-footer { display: none; }
}
