/* src/web/styles.css */
:root {
  --ink: #344248;
  --paper: #f9f0d7;
  --paper-warm: #f7e9c7;
  --desk: #c6d8d1;
  --kraft: #bb936b;
  --muted: #62756e;
  --shadow: #9fac99;
  --accent: #e9cb87;
  --danger: #b8574f;
  --hand: "Kalam", "Patrick Hand", "Segoe Print", "Comic Sans MS", cursive;
  --label: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--label);
  -webkit-text-size-adjust: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-weight: 700;
}

body {
  position: fixed;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  inset: 0;
}

#arena {
  position: fixed;
  display: block;
  touch-action: none;
  width: 100%;
  height: 100%;
  inset: 0;
}

.hud {
  position: fixed;
  display: flex;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  pointer-events: none;
  align-items:  flex-start;
  gap: 16px;
  top: 0;
  left: 0;
  right: 0;
}

.hud-title {
  font-family: var(--hand);
  flex: none;
  font-size: 26px;
  font-weight: 700;
  line-height: .98;
  transform: rotate(-4deg);
}

.hud-title span {
  display: block;
  font-family: var(--label);
  padding-left: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.6;
}

.hud-scores {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  flex: auto;
  justify-content: center;
  gap: 6px 22px;
  margin: 4px 0 0;
  padding: 0;
}

.hud-scores li {
  display: flex;
  align-items:  center;
  gap: 7px;
  min-width: 76px;
}

.hud-scores canvas {
  flex: none;
  width: 34px;
  height: 34px;
}

.hud-name {
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  max-width: 96px;
  font-size: 10px;
  font-weight: 900;
}

.hud-score {
  font-family: var(--hand);
  display: block;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.hud-scores li.is-local .hud-name {
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.hud-scores li.is-out {
  opacity: .45;
}

.hud-scores li {
  position: relative;
}

.hud-scores .hud-mark {
  display: none;
  position: absolute;
  width: 16px;
  height: 20px;
  top: -5px;
  left: 22px;
}

.hud-scores li.is-away .hud-mark {
  display: block;
}

.hud-scores li.is-away > canvas:first-child, .hud-scores li.is-gone > canvas:first-child {
  opacity: .42;
}

.hud-scores li.is-gone .hud-name {
  color: var(--muted);
}

.hud-note {
  font-family: var(--hand);
  color: var(--muted);
  align-self:  flex-end;
  margin-bottom: 1px;
  font-size: 15px;
  font-weight: 400;
  transform: rotate(-4deg);
}

.hud-note:empty {
  display: none;
}

.hud-clock {
  display: flex;
  text-align: center;
  flex-direction: column;
  flex: none;
  align-items:  center;
}

.hud-clock span {
  font-size: 9px;
  font-weight: 800;
}

.hud-clock strong {
  font-family: var(--hand);
  border-bottom: 2px solid #8e9e8b;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.hud-clock.is-urgent strong {
  color: var(--danger);
}

.hint, .device-note {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  color: var(--ink);
  pointer-events: none;
  font-size: 11px;
}

.hint {
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items:  flex-start;
  gap: 3px;
}

.hint-row {
  display: flex;
  align-items:  center;
  gap: 7px;
}

.hint .key {
  border: 1px solid #6e8072;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 9px;
  font-weight: 900;
}

.device-note {
  display: flex;
  right: max(16px, env(safe-area-inset-right));
  font-family: var(--hand);
  align-items:  center;
  gap: 7px;
  font-size: 15px;
  transform: rotate(-2deg);
}

.device-note canvas {
  width: 72px;
  height: 30px;
}

@media (pointer: coarse) {
  .device-note {
    max-width: 58vw;
    font-size: 13px;
    left: 50%;
    right: auto;
    transform: translateX(-50%)rotate(-2deg);
  }

  .device-note canvas {
    width: 56px;
    height: 24px;
  }
}

.pads {
  position: fixed;
  pointer-events: none;
  inset: 0;
}

.pads-move, .pads-act {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items:  flex-end;
  gap: 12px;
}

.pads-move {
  left: max(14px, env(safe-area-inset-left));
}

.pads-act {
  right: max(14px, env(safe-area-inset-right));
}

.pad {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  font-family: var(--label);
  background: #f9f0d7e0;
  border-bottom-width: 4px;
  border-radius: 9px 6px 10px 7px;
  flex-direction: column;
  justify-content: center;
  align-items:  center;
  gap: 0;
  width: 64px;
  min-width: 44px;
  height: 64px;
  min-height: 44px;
  padding: 0;
  font-size: 10px;
  font-weight: 900;
}

.pad svg {
  width: 34px;
  height: 34px;
}

.pad-jump {
  border-radius: 46% 51% 48% 49%;
  width: 66px;
  height: 66px;
}

.pad-fire {
  background: #e9cb87f0;
  border-radius: 46% 51% 48% 49%;
  width: 82px;
  height: 82px;
}

.pad-fire svg {
  width: 40px;
  height: 40px;
}

.pad.is-pressed {
  box-shadow: 1px 1px 0 var(--shadow);
  background: var(--accent);
  border-bottom-width: 2px;
  transform: translate(2px, 2px);
}

.pad:focus-visible {
  outline: 3px solid #256e87;
  outline-offset: 3px;
}

.panel {
  position: fixed;
  display: flex;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow: auto;
  overscroll-behavior: contain;
  justify-content: center;
  align-items:  center;
  inset: 0;
}

.panel[hidden] {
  display: none;
}

.card {
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 10px 7px 12px 8px;
  width: min(440px, 100%);
  max-height: 100%;
  padding: 20px 22px 22px;
  transform: rotate(-.5deg);
  box-shadow: 5px 6px #7a897c8c;
}

.card[hidden] {
  display: none;
}

.card h1 {
  font-family: var(--hand);
  margin: 0 0 6px;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
}

.card h2 {
  font-family: var(--hand);
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.card h2 strong {
  font-family: var(--label);
  letter-spacing: .14em;
  border-bottom: 2px dashed #b3a988;
  font-size: 22px;
}

.lede {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.field {
  display: block;
  margin: 0 0 10px;
}

.field span {
  display: block;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 900;
}

.field input, .invite input {
  font: inherit;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  background: #fffaea;
  border-radius: 7px 5px 8px 6px;
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  font-size: 16px;
}

.field input:focus-visible {
  outline: 3px solid #256e87;
  outline-offset: 2px;
}

.invite input:focus-visible {
  outline: 3px solid #256e87;
  outline-offset: 2px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.button {
  font: inherit;
  color: var(--ink);
  background: var(--paper-warm);
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  border-bottom-width: 4px;
  border-radius: 9px 6px 10px 7px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 900;
}

.button:active:not(:disabled) {
  box-shadow: 1px 1px 0 var(--shadow);
  border-bottom-width: 2px;
  transform: translate(2px, 2px);
}

.button.primary {
  background: var(--accent);
}

.button.ghost {
  box-shadow: none;
  background: none;
  border-bottom-width: 1.5px;
}

.button.small {
  padding: 8px 12px;
  font-size: 12px;
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.button:focus-visible {
  outline: 3px solid #256e87;
  outline-offset: 3px;
}

.divider {
  display: flex;
  color: var(--muted);
  align-items:  center;
  gap: 10px;
  margin: 14px 0 10px;
  font-size: 11px;
  font-weight: 900;
}

.divider:before, .divider:after {
  content: "";
  background: #d5cbac;
  flex: auto;
  height: 1px;
}

.note {
  color: var(--muted);
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.note.is-error {
  color: var(--danger);
}

.note:empty {
  min-height: 0;
  margin: 0;
}

.invite {
  display: flex;
  color: var(--muted);
  flex-wrap: wrap;
  align-items:  center;
  gap: 8px;
  margin: 12px 0;
  font-size: 11px;
  font-weight: 800;
}

.invite span {
  flex: 1 0 100%;
}

.invite input {
  flex: 200px;
  font-size: 13px;
  font-weight: 700;
}

.copy-note {
  color: var(--muted);
  flex: 1 0 100%;
  font-size: 11px;
  font-weight: 700;
}

.roster {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
}

.roster li {
  display: flex;
  background: #fdf7e6;
  border: 1.5px dashed #cfc4a4;
  border-radius: 8px 6px 9px 7px;
  align-items:  center;
  gap: 10px;
  padding: 6px 8px;
}

.roster canvas {
  flex: none;
  width: 34px;
  height: 34px;
}

.roster .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
}

.roster .tag {
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-left: auto;
  font-size: 10px;
  font-weight: 900;
}

.results {
  list-style: none;
  display: flex;
  counter-reset: place;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
}

.results li {
  display: flex;
  background: #fdf7e6;
  border: 1.5px solid #0000;
  border-radius: 8px 6px 9px 7px;
  align-items:  center;
  gap: 10px;
  padding: 7px 9px;
}

.results li.is-winner {
  border-color: var(--ink);
  background: var(--accent);
}

.results canvas {
  flex: none;
  width: 32px;
  height: 32px;
}

.results .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
}

.results .points {
  font-family: var(--hand);
  margin-left: auto;
  font-size: 24px;
  font-weight: 700;
}

.results-stage {
  display: block;
  border-bottom: 1.5px dashed #d5cbac;
  width: 100%;
  height: 150px;
  margin: -6px 0 4px;
}

@media (max-height: 520px) and (min-width: 540px) {
  .card-results {
    display: grid;
    grid-template-columns: minmax(190px, 36%) 1fr;
    align-items: stretch;
    column-gap: 16px;
    width: min(700px, 100%);
  }

  .results-stage {
    border-bottom: none;
    border-right: 1.5px dashed #d5cbac;
    height: auto;
    min-height: 180px;
    margin: 0;
  }

  .card-results h2 {
    margin-bottom: 4px;
    font-size: 24px;
  }

  .card-results .results {
    gap: 4px;
    margin-top: 6px;
  }

  .card-results .results li {
    padding: 4px 8px;
  }

  .card-results .row {
    margin-top: 8px;
  }
}

@media (max-height: 360px) and (min-width: 540px) {
  .card-results h2 {
    font-size: 20px;
  }

  .card-results .results {
    gap: 2px;
    margin-top: 4px;
  }

  .card-results .results li {
    padding: 1px 8px;
  }

  .card-results .results canvas {
    width: 28px;
    height: 28px;
  }

  .card-results .row {
    margin-top: 6px;
  }
}

.results .left-early {
  font-family: var(--hand);
  color: var(--muted);
  white-space: nowrap;
  font-size: 16px;
  font-weight: 400;
  transform: rotate(-3deg);
}

.results li.is-gone > canvas {
  opacity: .42;
}

.results li.is-gone .who {
  color: var(--muted);
}

.note.is-benched {
  font-family: var(--hand);
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}

.host-wait {
  position: fixed;
  display: flex;
  pointer-events: none;
  background: #c6d8d152;
  justify-content: center;
  align-items:  flex-start;
  padding-top: max(19vh, 70px);
  inset: 0;
}

.host-wait-note {
  position: relative;
  filter: drop-shadow(4px 5px 0 #7a897c8c);
  transform: rotate(-2deg);
}

.host-wait-slip {
  display: grid;
  grid-template-columns: auto auto;
  background: var(--paper);
  color: var(--ink);
  clip-path: polygon(0% 6%, 7% 1%, 19% 4%, 33% 0%, 48% 3%, 61% 0%, 76% 4%, 89% 1%, 100% 5%, 98% 28%, 100% 52%, 97% 76%, 100% 96%, 86% 100%, 71% 96%, 55% 100%, 40% 97%, 24% 100%, 9% 96%, 0% 99%, 2% 72%, 0% 47%, 3% 24%);
  align-items:  center;
  column-gap: 12px;
  padding: 16px 30px 14px 22px;
}

.host-wait-note:before, .host-wait-note:after {
  content: "";
  position: absolute;
  background: #d6c296bd;
  width: 46px;
  height: 17px;
  top: -3px;
}

.host-wait-note:before {
  left: 10px;
  transform: rotate(-14deg);
}

.host-wait-note:after {
  right: 12px;
  transform: rotate(11deg);
}

#host-wait-mark {
  grid-row: span 2;
  width: 30px;
  height: 34px;
}

.host-wait-title {
  font-family: var(--hand);
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
}

.host-wait-clock {
  font-family: var(--hand);
  border-bottom: 2px solid #8e9e8b;
  justify-self: start;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

@media (max-height: 520px) {
  .host-wait {
    padding-top: max(24vh, 62px);
  }

  .host-wait-slip {
    column-gap: 10px;
    padding: 11px 24px 10px 16px;
  }

  .host-wait-title {
    font-size: 21px;
  }

  .host-wait-clock {
    font-size: 32px;
  }
}

.rotate {
  position: fixed;
  display: flex;
  z-index: 5;
  background: #c6d8d1f5;
  justify-content: center;
  align-items:  center;
  inset: 0;
}

.rotate[hidden] {
  display: none;
}

.rotate-card {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  text-align: center;
  border-radius: 10px 7px 12px 8px;
  max-width: 320px;
  padding: 18px 22px;
  transform: rotate(-1deg);
  box-shadow: 5px 6px #7a897c8c;
}

.rotate-card p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-height: 520px) {
  .card {
    padding: 14px 16px 16px;
  }

  .card h1 {
    font-size: 30px;
  }

  .lede {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .hud-title {
    display: none;
  }
}

@media (max-width: 620px) {
  .hud-title {
    font-size: 20px;
  }

  .hud-scores li {
    gap: 5px;
    min-width: 64px;
  }

  .hud-scores canvas {
    width: 28px;
    height: 28px;
  }

  .hud-score {
    font-size: 22px;
  }

  .hud-clock strong {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pad.is-pressed, .button:active:not(:disabled) {
    transform: none;
  }
}
