:root {
  --ink: #fff7e0;
  --ink-soft: rgba(255, 240, 215, 0.78);
  --bg: #140c08;
  --card: rgba(28, 15, 8, 0.86);
  --edge: rgba(255, 207, 90, 0.28);
  --gold: #ffcf5a;
  --red: #c8281c;
  --red-hi: #e8432f;
  --p1: #ff5a3c;
  --p2: #33b8ff;
  --title: 'Shojumaru', 'Fredoka', serif;
  --body: 'Fredoka', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#cam { display: none; }
#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.hidden { display: none !important; }
button { font-family: inherit; }
a { color: var(--gold); }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 35%, rgba(140, 30, 18, 0.35), rgba(10, 5, 2, 0.88) 70%);
  overflow-y: auto;
  z-index: 5;
}
.card {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 22px;
  padding: clamp(20px, 4vw, 36px);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
}
.card.small { width: min(380px, 100%); }
.card h2 { font-family: var(--title); font-weight: 400; margin: 0 0 14px; font-size: 32px; letter-spacing: 0.02em; }

.logo { position: relative; margin: 0 0 8px; }
.logo h1, h1.mini {
  font-family: var(--title);
  font-weight: 400;
  margin: 0;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 0 #5a1208, 0 10px 30px rgba(0, 0, 0, 0.6);
}
.logo h1 { font-size: clamp(48px, 11vw, 88px); }
.logo h1 span:first-child, h1.mini span:first-child { color: var(--gold); }
.logo h1 span:last-child, h1.mini span:last-child { color: var(--ink); }
.logo .band {
  display: block;
  height: 14px;
  margin: 0 auto 14px;
  width: min(320px, 70%);
  background: linear-gradient(90deg, transparent, var(--red) 12%, var(--red-hi) 50%, var(--red) 88%, transparent);
  border-radius: 7px;
  position: relative;
}
.logo .band::after {
  content: '';
  position: absolute;
  right: 6%;
  top: 6px;
  width: 54px;
  height: 12px;
  background: var(--red);
  border-radius: 6px;
  transform: rotate(24deg);
  transform-origin: left center;
}
.tag { font-size: clamp(17px, 2.4vw, 20px); color: var(--ink-soft); margin: 10px 0 22px; font-weight: 500; }

.actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.actions button, .seg button {
  cursor: pointer;
  border-radius: 999px;
  font-weight: 600;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.15s, box-shadow 0.15s;
}
.actions button { font-size: 19px; padding: 15px 22px; display: inline-flex; gap: 10px; align-items: center; justify-content: center; }
.actions button:active { transform: scale(0.97); }
.primary {
  background: linear-gradient(180deg, var(--red-hi), var(--red));
  color: #fff;
  border: 0;
  box-shadow: 0 6px 0 #6e1209, 0 12px 26px rgba(200, 40, 28, 0.35);
}
.primary:hover { filter: brightness(1.08); }
.primary svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
.ghost { background: transparent; color: var(--ink); border: 2px solid rgba(255, 240, 215, 0.3); }
.ghost:hover { border-color: var(--gold); }
#status { min-height: 1.4em; margin: 14px 0 0; color: var(--gold); font-weight: 500; }
#status.bad { color: #ff8a73; }

.tips { list-style: none; padding: 0; margin: 18px 0 0; text-align: left; display: grid; gap: 8px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-soft); font-size: 16px; line-height: 1.35; }
.tips span { font-size: 20px; line-height: 1.1; }
.fine { font-size: 13.5px; color: rgba(255, 240, 215, 0.6); margin: 18px 0 0; }
.credit { font-size: 13.5px; margin: 8px 0 0; }
.credit a { color: var(--ink-soft); text-underline-offset: 3px; }

/* Privacy and credit, dim in the bottom corner so they don't pull eyes off the food.
   They stay on every screen size. */
#corner {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  font-weight: 500;
  z-index: 4;
  opacity: 0.6;
  transition: opacity 0.2s;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}
#corner:hover, #corner:focus-within { opacity: 1; }
#corner a { color: var(--ink); text-decoration: none; padding: 6px 0; }
#corner a:hover { text-decoration: underline; }

#menuTitle {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  width: min(92vw, 900px);
  z-index: 2;
}
h1.mini { font-size: clamp(40px, 8vh, 76px); }
#menuHint { margin: 10px 0 0; font-size: clamp(15px, 2.4vh, 20px); color: var(--ink-soft); font-weight: 500; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }

#results {
  position: fixed;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: center;
  padding: max(16px, 4vh) 16px 0;
  pointer-events: none;
  z-index: 3;
}
#results .card { width: min(640px, 100%); padding: clamp(16px, 3vh, 28px); pointer-events: auto; animation: rise 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.15); }
@keyframes rise { from { transform: translateY(-24px) scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
#results .why { margin: 0 0 6px; color: var(--ink-soft); font-weight: 500; font-size: 16px; }
#results h2 { margin: 2px 0 0; font-size: clamp(28px, 5vh, 42px); }
#results .big { font-family: var(--body); font-weight: 700; font-size: clamp(52px, 11vh, 96px); line-height: 1; margin: 6px 0 2px; color: var(--gold); display: block; }
#results .best { margin: 0; color: var(--ink-soft); font-weight: 600; }
.belt { width: min(200px, 50%); height: auto; display: block; margin: 4px auto 0; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45)); }
.stats { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; padding: 0; margin: 12px 0 0; color: var(--ink-soft); font-size: 15px; }
.stats b { color: var(--ink); font-size: 20px; margin-right: 4px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.duo > div { border-radius: 16px; padding: 12px 8px; background: rgba(255, 255, 255, 0.04); border: 2px solid transparent; }
.duo .p1 { border-color: color-mix(in srgb, var(--p1) 45%, transparent); }
.duo .p2 { border-color: color-mix(in srgb, var(--p2) 45%, transparent); }
.duo .win { background: rgba(255, 207, 90, 0.1); box-shadow: 0 0 0 3px var(--gold); }
.duo .who { font-weight: 700; font-size: 17px; }
.duo .p1 .who { color: var(--p1); }
.duo .p2 .who { color: var(--p2); }
.duo .big { font-size: clamp(40px, 8vh, 72px) !important; }
.duo .beltname { display: block; font-weight: 600; color: var(--ink-soft); margin-top: 2px; }
.duo .stats { font-size: 13px; gap: 4px 10px; }
.duo .stats b { font-size: 16px; }
.duo .belt { width: min(140px, 80%); }

#gear {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 240, 215, 0.25);
  background: rgba(20, 10, 4, 0.55);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 6;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.3s;
}
#gear:hover { opacity: 1; transform: rotate(40deg); }
#gear svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.panel {
  position: fixed;
  top: 64px;
  right: 12px;
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 16px 18px;
  z-index: 7;
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel h2 { font-family: var(--title); font-weight: 400; margin: 0; font-size: 22px; }
.x { background: none; border: 0; color: var(--ink); font-size: 18px; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; }
.x:hover { background: rgba(255, 255, 255, 0.08); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid rgba(255, 240, 215, 0.08); }
.row > span { font-weight: 500; color: var(--ink-soft); }
.seg { display: flex; gap: 4px; background: rgba(0, 0, 0, 0.3); padding: 3px; border-radius: 999px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { border: 0; background: transparent; color: var(--ink-soft); padding: 7px 12px; font-size: 14px; }
.seg button[aria-pressed='true'] { background: var(--gold); color: #2a1406; }
.keys { font-size: 13px; color: rgba(255, 240, 215, 0.55); margin: 10px 0 0; }
kbd { font-family: inherit; border: 1px solid rgba(255, 240, 215, 0.3); border-radius: 5px; padding: 0 5px; }

@media (max-height: 520px) {
  .tips { display: none; }
  .logo h1 { font-size: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  #results .card { animation: none; }
}
