/* Visual de gibi: tinta preta, papel creme, vermelho de onomatopeia. A cena em si vem dos sprites. */
:root {
  --paper: #f2c230;
  --ink: #1b1712;
  --pop: #d8322a;
  --cream: #fff6dc;
  --white: #ffffff;
  --display: 'Bangers', 'Impact', 'Arial Black', sans-serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #8fd0f2;
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; -webkit-user-select: none; user-select: none;
  cursor: grab;
}
canvas:active { cursor: grabbing; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  display: grid; gap: 10px; pointer-events: none;
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag {
  font-family: var(--display); font-size: 30px; letter-spacing: .04em; line-height: 1.05;
  background: var(--cream); color: var(--ink);
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 2px 12px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tag.time.low { background: var(--pop); color: var(--cream); }
.meter {
  position: relative; height: 26px; overflow: hidden;
  border: 3px solid var(--ink); background: var(--cream); box-shadow: 3px 3px 0 var(--ink);
}
.meter i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  background: repeating-linear-gradient(-45deg, var(--pop) 0 10px, #b3241c 10px 20px);
  transition: width .08s linear;
}
.meter span {
  position: absolute; inset: 0; display: flex; align-items: center; padding-left: 10px;
  font-family: var(--display); font-size: 18px; letter-spacing: .1em;
}

.big {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--display); font-size: clamp(110px, 38vw, 220px); line-height: 1;
  color: var(--pop); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  text-shadow: 6px 6px 0 var(--ink);
}
.big.go { color: var(--paper); }
.big.anim { animation: bump .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes bump { from { transform: scale(.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

.hint {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  margin: 0 auto; max-width: 420px; box-sizing: border-box;
  text-align: center; font-weight: 800; font-size: 14px; line-height: 1.35;
  background: var(--ink); color: var(--cream); padding: 8px 12px; pointer-events: none;
  text-wrap: balance;
}

/* ---------- telas ---------- */
.overlay {
  position: fixed; inset: 0; display: flex; overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: rgba(27, 23, 18, .4);
}
.card {
  margin: auto; width: 100%; max-width: 400px; box-sizing: border-box;
  background: var(--cream); color: var(--ink);
  border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink);
  padding: 22px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px;
}
.card h1, .card h2 {
  font-family: var(--display); font-weight: 400; margin: 0; line-height: .92; letter-spacing: .02em;
  color: var(--pop); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-wrap: balance;
}
.card h1 { font-size: clamp(54px, 16vw, 76px); transform: rotate(-2deg); transform-origin: left; }
.card h2 { font-size: clamp(42px, 12vw, 56px); font-variant-numeric: tabular-nums; }
.card h3 { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: .06em; margin: 0; }
.card p { margin: 0; line-height: 1.45; font-size: 15px; }
.eyebrow { font-weight: 800; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.small { font-size: 13px !important; opacity: .8; }

.btn {
  font-family: var(--display); font-size: 28px; letter-spacing: .06em;
  background: var(--pop); color: var(--cream);
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 16px; cursor: pointer;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn:focus-visible, .field input:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
.small-btn { flex: none; font-size: 22px; padding: 6px 14px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.field label { font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.inline { display: flex; gap: 8px; }
.field input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 700;
  padding: 8px 10px; border: 3px solid var(--ink); background: var(--white); color: var(--ink);
  border-radius: 0;
}
.msg { font-weight: 700; min-height: 0; }
.msg:empty { display: none; }
.msg.err { color: var(--pop); }

.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; border-top: 3px solid var(--ink); padding-top: 12px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.rank li {
  display: grid; grid-template-columns: 2em minmax(0, 1fr) auto auto; gap: 8px; align-items: baseline;
  padding: 4px 8px; border: 2px solid var(--ink); background: var(--white);
  font-variant-numeric: tabular-nums;
}
.rank li.me { background: var(--paper); }
.rank .pos, .rank .pts { font-family: var(--display); font-size: 20px; letter-spacing: .03em; }
.rank .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .in { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .6; }

@media (max-width: 380px), (max-height: 700px) {
  .card { padding: 16px 14px; gap: 10px; }
  .card h2 { font-size: 40px; }
  .rank li { padding: 2px 8px; }
  .rank .pos, .rank .pts { font-size: 18px; }
  .btn { font-size: 24px; padding: 8px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .big.anim { animation: none; }
  .meter i { transition: none; }
}
