/* fighters — the whole interface is meant to look like the sheet of paper the
   game was designed on. Cream, graphite, wobbly edges, handwriting. */

:root {
  --paper: #f7f2e7;
  --paper-2: #ece3d1;
  --ink: #41403c;
  --ink-soft: #6d6a63;
  --ink-light: #a6a199;
  --pink: #e78bb0;
  --red: #d4562f;
  --hand: "Chalkboard SE", "Comic Sans MS", "Bradley Hand", "Segoe Print", "Marker Felt", cursive;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bub: clamp(46px, 9.2vh, 74px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  touch-action: none;
  user-select: none;
}
body { position: fixed; inset: 0; width: 100%; }

canvas#game { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }
.hand { font-family: var(--hand); }

.paper {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.75), transparent 55%),
    radial-gradient(circle at 84% 82%, rgba(0,0,0,.05), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.05'/></svg>");
}

/* ------------------------------------------------------------- screens */

#ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: clamp(6px, 1.6vh, 16px);
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(10px + var(--safe-b));
  pointer-events: auto;
  overflow: hidden;
}
.screen.dim { background: rgba(247,242,231,.86); }
/* the title sits on tracing paper — you can see the fight going on behind it */
#title.paper { background-color: rgba(247,242,231,.82); }

.sheet { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 220px 16px 240px 18px / 18px 230px 16px 250px;
  padding: clamp(16px, 4vh, 34px) clamp(22px, 6vw, 54px);
  box-shadow: 3px 4px 0 rgba(65,64,60,.12);
}

h1.big {
  font-size: clamp(56px, 15vh, 132px);
  margin: 0; line-height: .95; letter-spacing: -.02em;
  transform: rotate(-1.6deg);
}
.squiggle { width: min(70vw, 420px); height: 14px; margin-top: -6px; opacity: .8; }
h2.hand { font-size: clamp(24px, 4.6vh, 40px); margin: 0 0 4px; transform: rotate(-.8deg); }
h3 { font-size: clamp(17px, 2.6vh, 24px); margin: 0 0 6px; }
.sub { font-size: clamp(15px, 2.4vh, 22px); color: var(--ink-soft); margin: 0; }
.credit { font-size: clamp(13px, 1.9vh, 17px); color: var(--ink-light); margin: 6px 0 0; }

/* hand-drawn oval button, like the Play oval on the sheet */
.oval {
  font-family: var(--hand);
  font-size: clamp(20px, 3.4vh, 32px);
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 50% / 44%;
  padding: clamp(8px, 1.6vh, 16px) clamp(26px, 6vw, 56px);
  cursor: pointer;
  transition: transform .1s ease, background .1s ease;
  box-shadow: 2px 3px 0 rgba(65,64,60,.16);
}
.oval:hover { background: var(--paper-2); }
.oval:active { transform: translate(2px, 3px) scale(.98); box-shadow: none; }
.oval.small { font-size: clamp(15px, 2.2vh, 20px); padding: 7px 22px; border-width: 2.5px; }

.row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.blurb { font-size: clamp(14px, 2.1vh, 19px); color: var(--ink-soft); margin: 0; min-height: 1.4em; max-width: 60ch; text-align: center; }

/* ------------------------------------------------------- character sheet */

#teams {
  display: flex; align-items: stretch; justify-content: center;
  gap: clamp(4px, 1.6vw, 22px);
  width: 100%; max-width: 1180px;
}
.team { flex: 1; text-align: center; min-width: 0; }
.rip { width: 26px; flex: 0 0 26px; height: auto; opacity: .55; }
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(4px, 1.1vw, 12px);
  justify-items: center;
}
.team[data-team="red"] .cards { grid-template-columns: repeat(2, 1fr); }

.card-fighter {
  width: 100%;
  max-width: 148px;
  background: none;
  border: 2.6px solid transparent;
  border-radius: 140px 12px 150px 14px / 14px 150px 12px 160px;
  padding: 4px 2px 2px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--hand);
  color: var(--ink);
  transition: transform .12s ease;
}
.card-fighter canvas { width: 100%; height: auto; display: block; }
.card-fighter .nm { font-size: clamp(13px, 2vh, 18px); margin-top: -6px; }
.card-fighter:hover { transform: translateY(-3px) rotate(-1deg); }
.card-fighter.on { border-color: var(--ink); background: rgba(255,255,255,.5); }
.card-fighter.on .nm { font-weight: 700; }

/* ------------------------------------------------------------ mode sheet */

#picked-art { width: clamp(80px, 15vh, 130px); height: auto; margin-bottom: -6px; }
#mode-list { display: flex; gap: clamp(8px, 2vw, 22px); flex-wrap: wrap; justify-content: center; }
.mode {
  font-family: var(--hand);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 180px 18px 190px 16px / 16px 200px 18px 190px;
  padding: clamp(12px, 2.6vh, 26px) clamp(16px, 3vw, 34px);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  width: clamp(180px, 27vw, 260px);
  color: var(--ink);
  box-shadow: 2px 3px 0 rgba(65,64,60,.14);
  transition: transform .1s ease;
}
.mode:hover { background: var(--paper-2); transform: translateY(-2px); }
.mode:active { transform: translate(2px, 3px); box-shadow: none; }
.mtitle { font-size: clamp(24px, 4vh, 38px); }
.mdesc { font-size: clamp(12px, 1.8vh, 16px); color: var(--ink-soft); line-height: 1.25; }

.toggle { display: flex; align-items: center; gap: 10px; font-size: clamp(14px, 2.1vh, 19px); color: var(--ink-soft); cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--red); }
.picked { font-size: clamp(14px, 2vh, 19px); color: var(--ink-soft); margin: 0; }

/* ------------------------------------------------------------- the bar */

#bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 8;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
  pointer-events: none;
}
#bar > * { pointer-events: auto; }

#pad {
  position: relative;
  width: min(calc(var(--bub) * 2.35), 42vh);
  height: min(calc(var(--bub) * 2.35), 42vh);
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(247,242,231,.72);
  touch-action: none;
  flex: none;
}
#pad .nub {
  position: absolute; left: 50%; top: 50%;
  width: 26%; height: 26%; margin: -13% 0 0 -13%;
  border: 2.6px solid var(--ink); border-radius: 50%;
}
#pad .arrow {
  position: absolute; width: 0; height: 0;
  border: 11px solid transparent;
  opacity: .75;
}
#pad .up { top: 5%; left: 50%; margin-left: -11px; border-bottom-color: var(--ink); border-top-width: 0; }
#pad .down { bottom: 5%; left: 50%; margin-left: -11px; border-top-color: var(--ink); border-bottom-width: 0; }
#pad .left { left: 5%; top: 50%; margin-top: -11px; border-right-color: var(--ink); border-left-width: 0; }
#pad .right { right: 5%; top: 50%; margin-top: -11px; border-left-color: var(--ink); border-right-width: 0; }
#pad.u .up, #pad.d .down, #pad.l .left, #pad.r .right { opacity: 1; filter: drop-shadow(0 0 4px rgba(65,64,60,.6)); }

#buttons {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: clamp(5px, 1.1vh, 12px);
  align-items: end;
  justify-items: center;
}
.bub {
  width: var(--bub); height: var(--bub);
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(247,242,231,.82);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 0;
  cursor: pointer;
  touch-action: none;
}
.bub canvas { width: 74%; height: 74%; margin-bottom: 14%; }
/* the caption lives inside the circle, so nothing can be clipped off the
   bottom of a short landscape phone */
.bub b {
  position: absolute; bottom: 6%; left: 50%; transform: translateX(-50%);
  font-family: var(--hand); font-size: clamp(8px, 1.55vh, 11px); font-weight: 400;
  color: var(--ink-soft); white-space: nowrap; line-height: 1;
}
.bub.big { width: calc(var(--bub) * 1.22); height: calc(var(--bub) * 1.22); }
.bub.down { background: var(--paper-2); transform: scale(.94); }
.bub.star { opacity: .45; }
.bub.star.ready { opacity: 1; animation: pop 1s ease-in-out infinite; }
@keyframes pop { 50% { transform: scale(1.08) rotate(4deg); } }

.corner {
  position: fixed; z-index: 9;
  top: calc(8px + env(safe-area-inset-top)); right: calc(10px + var(--safe-r));
  width: 44px; height: 44px;
  border: 3px solid var(--ink); border-radius: 50%;
  background: rgba(247,242,231,.8);
  font-family: var(--hand); font-size: 18px; color: var(--ink);
  letter-spacing: 2px; cursor: pointer;
}

#rotate { z-index: 20; }
.phone-turn {
  width: 74px; height: 122px;
  border: 3.5px solid var(--ink); border-radius: 14px;
  position: relative;
  animation: turnphone 2.6s ease-in-out infinite;
}
.phone-turn::after {
  content: ""; position: absolute; left: 50%; bottom: 7px;
  width: 26px; height: 3px; margin-left: -13px;
  background: var(--ink); border-radius: 2px;
}
@keyframes turnphone {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

/* short landscape phones: shrink everything that is not the fight */
@media (max-height: 480px) {
  :root { --bub: clamp(36px, 13.4vh, 54px); }
  .cards { gap: 3px; }
  .card-fighter { max-width: 108px; }
  .credit { display: none; }
}

@media (orientation: portrait) and (max-width: 820px) {
  #teams { flex-direction: column; }
  .rip { display: none; }
  .team[data-team="red"] .cards { grid-template-columns: repeat(3, 1fr); }
}
