/* Shared look for the Jameses Gameses math games */
:root {
  color-scheme: dark;
  --ink: #0b0614;
  --paper: #ffe34a;
  --foam: #f7fbff;
  --cyan: #19e7ff;
  --pink: #ff4fa3;
  --green: #2be08a;
  --red: #ff4b4b;
  --purple: #8b4dff;
  --card: #3a2a7a;
  --num: "Atkinson Hyperlegible", "Trebuchet MS", Verdana, system-ui, sans-serif;
  --head: Bangers, Impact, "Arial Black", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #14093a;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body { font-family: Nunito, "Trebuchet MS", system-ui, sans-serif; color: var(--foam); }
button { font-family: inherit; color: inherit; }

#app {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1c0f52 0%, #14093a 60%, #0c0624 100%);
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  text-align: center;
}

.kicker { margin: 4px 0 0; font-weight: 900; font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); }

h1 {
  margin: 6px 0 4px;
  font-family: var(--head);
  font-weight: 400;
  font-size: clamp(2.4rem, 13vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  color: var(--paper);
  text-shadow: 3px 3px 0 var(--ink), 0 0 20px rgba(139, 77, 255, 0.6);
}

.lead { margin: 4px 0 10px; font-weight: 800; font-size: 1rem; line-height: 1.3; max-width: 34ch; }
.label { margin: 10px 0 6px; font-weight: 900; font-size: 0.9rem; color: var(--paper); }
.note { margin: 6px 0; font-weight: 800; font-size: 0.85rem; color: #cfc3ff; }
.best { margin: 8px 0 6px; font-weight: 900; color: var(--cyan); }

/* Setup screen: settings scroll, start button stays at the bottom */
.setup { padding: 0; overflow: hidden; align-items: stretch; }
.setup-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  -webkit-overflow-scrolling: touch;
}
.startbar {
  flex: none; display: flex; justify-content: center; gap: 10px;
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
  background: #0c0624; border-top: 4px solid var(--ink);
}

.big {
  width: min(100%, 380px);
  min-height: 62px;
  margin-top: 10px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff8cf 0%, var(--paper) 100%);
  color: var(--ink);
  font: 400 1.8rem var(--head);
  letter-spacing: 0.05em;
  box-shadow: 5px 5px 0 var(--ink);
}
.big.alt { min-height: 52px; background: var(--card); color: var(--foam); font-size: 1.35rem; }
.big:active { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.big:disabled { opacity: 0.4; }
.startbar .big { margin-top: 0; }

.mini {
  min-height: 44px; padding: 0 16px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: var(--purple); color: #fff;
  font: 900 0.9rem Nunito, sans-serif;
  box-shadow: 3px 3px 0 var(--ink);
}
.mini:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* Picker: level, topics, tables */
.pk { width: min(100%, 380px); }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lv, .opt {
  min-height: 60px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  color: var(--foam);
  font: 900 0.8rem/1.2 Nunito, sans-serif;
  box-shadow: 3px 3px 0 var(--ink);
  opacity: 0.6;
}
.lv.on, .opt.on { background: linear-gradient(180deg, #c8f7ff 0%, var(--cyan) 100%); color: var(--ink); opacity: 1; }
.lv:active, .opt:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 380px); }

.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topic {
  display: flex; align-items: center; gap: 8px;
  min-height: 54px; padding: 6px 10px;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--card); color: var(--foam);
  font: 900 0.95rem/1.15 Nunito, sans-serif; text-align: left;
  box-shadow: 3px 3px 0 var(--ink); opacity: 0.6;
}
.topic .ico { flex: none; min-width: 26px; text-align: center; font-size: 1.3rem; }
.topic.on { background: linear-gradient(180deg, #fff8cf 0%, var(--paper) 100%); color: var(--ink); opacity: 1; }
.topic:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  min-height: 52px;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--card); color: var(--foam);
  font: 700 1.4rem var(--num);
  box-shadow: 3px 3px 0 var(--ink); opacity: 0.6;
}
.chip.on { background: linear-gradient(180deg, #fff8cf 0%, var(--paper) 100%); color: var(--ink); opacity: 1; }
.chip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* Play screens */
.topbar {
  flex: none; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
}
.pill {
  display: flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 4px 12px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: rgba(11, 6, 20, 0.7);
  font: 900 1rem Nunito, sans-serif;
}
.pill b { font-family: var(--num); color: var(--paper); }
.exit {
  min-width: 44px; min-height: 40px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: var(--card); font: 900 1rem Nunito, sans-serif;
}

.play { padding: 0; overflow: hidden; align-items: stretch; }

.stats { display: flex; gap: 10px; margin: 8px 0; width: min(100%, 380px); }
.stats div {
  flex: 1; padding: 10px 4px;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--card); box-shadow: 3px 3px 0 var(--ink);
}
.stats b { display: block; font: 700 1.6rem var(--num); color: var(--paper); }
.stats span { font-size: 0.75rem; font-weight: 900; }
.stars { font-size: 2.2rem; letter-spacing: 6px; margin: 4px 0; }

.hintchip {
  display: inline-block; margin-top: 6px; padding: 2px 12px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: var(--cyan); color: var(--ink);
  font-weight: 900; font-size: 0.85rem;
}

/* Four answer buttons */
.answers {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  background: #0c0624; border-top: 4px solid var(--ink);
}
.ans {
  min-height: 74px;
  border: 3px solid var(--ink); border-radius: 20px;
  background: linear-gradient(180deg, #fff8cf 0%, var(--paper) 100%);
  color: var(--ink);
  font: 700 2.1rem var(--num);
  box-shadow: 4px 4px 0 var(--ink);
}
.ans.small { font-size: 1.6rem; }
.ans:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.ans.right { background: var(--green); }
.ans.wrong { background: var(--red); color: #fff; }

@media (max-height: 640px) {
  .ans { min-height: 60px; font-size: 1.8rem; }
  h1 { font-size: 2.3rem; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* "Why" help. The coach strip has a fixed height so the game never jumps when a tip appears. */
.coach {
  flex: none;
  width: calc(100% - 24px);
  min-height: 3.4em;
  margin: 0 12px 6px;
  padding: 6px 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  text-align: center;
  font: 800 0.88rem/1.25 Nunito, sans-serif;
  color: #cfc3ff;
}
.coach.on { background: rgba(25, 231, 255, 0.14); color: var(--foam); }
.coach b { color: var(--paper); font-family: var(--num); }

.review { width: min(100%, 380px); margin: 10px 0 6px; text-align: left; }
.review .label { text-align: center; }
.review .item {
  margin-bottom: 8px; padding: 10px 12px;
  border: 3px solid var(--ink); border-radius: 14px;
  background: var(--card); box-shadow: 3px 3px 0 var(--ink);
}
.review .item b { display: block; font: 700 1.1rem var(--num); color: var(--paper); }
.review .item p { margin: 4px 0 0; font: 700 0.85rem/1.35 Nunito, sans-serif; color: #e8e0ff; }

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  margin-top: 2px;
  border: 3px solid var(--ink, #0b0614);
  border-radius: 999px;
  background: #3a2a7a;
  color: #fff;
  font: 900 0.95rem Nunito, sans-serif;
  text-decoration: none;
  box-shadow: 3px 3px 0 var(--ink, #0b0614);
}
