:root {
  --bg: #0d1117;
  --bg-2: #131a24;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #e8edf4;
  --muted: #93a1b5;
  --accent: #ff4d3d;
  --accent-2: #ff8a3d;
  --gold: #ffc93c;
  --green: #38d39f;
  --blue: #4da3ff;
  --radius: 14px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Roboto Mono', ui-monospace, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 700px at 12% -8%, #26303f 0%, transparent 55%),
    radial-gradient(900px 600px at 92% 4%, #2c1a1c 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 940px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* ---------- header + tabs ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand h1 {
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  font-weight: 800;
  background: linear-gradient(92deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .tag {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.tabs button:hover { color: var(--text); }

.tabs button[aria-selected='true'] {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* ---------- layout primitives ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.card > h3 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--gold);
  margin-bottom: 0.9rem;
  font-weight: 700;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

select, input[type='number'], input[type='text'] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 77, 61, 0.16);
}

select option { background: #182130; }

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.range-row output {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--gold);
  min-width: 3.6rem;
  text-align: right;
}

/* ---------- toggle chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.chip:hover { border-color: var(--line-strong); color: var(--text); }

.chip input { position: absolute; opacity: 0; pointer-events: none; }

.chip:has(input:checked) {
  background: rgba(255, 77, 61, 0.16);
  border-color: var(--accent);
  color: #fff;
}

.chip .sub {
  font-weight: 500;
  font-size: 0.75rem;
  opacity: 0.7;
}

.chip.num:has(input:checked) { background: rgba(255, 201, 60, 0.16); border-color: var(--gold); }

/* ---------- buttons ---------- */

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 6px 20px rgba(255, 77, 61, 0.28);
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 9px 26px rgba(255, 77, 61, 0.36); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--surface-2); box-shadow: none; }

.btn.small { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn.wide { width: 100%; }

.btn-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- presets ---------- */

.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; }

.preset {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: all 0.15s;
}
.preset:hover { border-color: var(--accent); background: rgba(255, 77, 61, 0.1); }
.preset strong { display: block; font-size: 0.92rem; margin-bottom: 0.15rem; }
.preset span { font-size: 0.75rem; color: var(--muted); }

/* ---------- custom combos ---------- */

.custom-row { display: flex; gap: 0.5rem; }
.custom-row input { flex: 1; font-family: var(--mono); }

.custom-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

.custom-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(77, 163, 255, 0.14);
  border: 1px solid rgba(77, 163, 255, 0.4);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.custom-item button {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.2rem;
}
.custom-item button:hover { color: var(--accent); }

.error { color: var(--accent); font-size: 0.8rem; margin-top: 0.5rem; min-height: 1.1em; }

/* ---------- pool preview ---------- */

.pool-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 1rem;
}

/* Flex items default to min-width:auto, so the nowrap sample line below would
 * push the whole page wider than the viewport instead of ellipsing. */
.pool-bar > div { flex: 1 1 200px; min-width: 0; }

.pool-count { font-size: 0.9rem; color: var(--muted); }
.pool-count b { color: var(--gold); font-size: 1.15rem; font-family: var(--mono); }

.pool-sample {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ---------- training screen ---------- */

.stage { text-align: center; padding: 1rem 0 0; }

.round-strip {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.pill {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.pill b { color: var(--text); font-family: var(--mono); }
.pill.live { border-color: var(--accent); color: #fff; background: rgba(255, 77, 61, 0.16); }
.pill.rest { border-color: var(--green); color: #fff; background: rgba(56, 211, 159, 0.14); }

.clock {
  font-family: var(--mono);
  font-size: clamp(3rem, 13vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.clock.warn { color: var(--gold); }

.progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  margin: 1rem 0 1.5rem;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(92deg, var(--accent), var(--gold));
  transition: width 0.25s linear;
}

.combo-stage {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.25rem 0.75rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 77, 61, 0.1), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
}

.combo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.move {
  font-weight: 800;
  line-height: 1;
  padding: 0.5rem 0.85rem;
  border-radius: 12px;
  font-size: clamp(1.8rem, 8vw, 3.4rem);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  animation: pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.move.punch { color: #fff; background: rgba(255, 77, 61, 0.3); border-color: rgba(255, 77, 61, 0.55); }
.move.body { color: var(--gold); background: rgba(255, 201, 60, 0.16); border-color: rgba(255, 201, 60, 0.45); }
.move.defense,
.move.footwork,
.move.basic {
  font-size: clamp(0.9rem, 3.2vw, 1.4rem);
  letter-spacing: 0.08em;
  padding: 0.55rem 0.8rem;
}
.move.defense { color: var(--blue); background: rgba(77, 163, 255, 0.14); border-color: rgba(77, 163, 255, 0.4); }
.move.footwork { color: var(--green); background: rgba(56, 211, 159, 0.13); border-color: rgba(56, 211, 159, 0.4); }

@keyframes pop {
  0% { transform: scale(0.86); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.combo-sub {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  min-height: 1.2em;
}

.rest-note {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--green);
}

.big-count {
  font-family: var(--mono);
  font-size: clamp(4rem, 22vw, 9rem);
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.7rem;
  margin: 1.5rem 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.5rem;
}
.stat .n { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; color: var(--gold); }
.stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.3rem; }

/* ---------- history ---------- */

.history { display: flex; flex-direction: column; gap: 0.4rem; }

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.history-row .when { color: var(--muted); font-size: 0.78rem; }
.history-row .figs { font-family: var(--mono); color: var(--gold); font-size: 0.82rem; }

/* ---------- legend ---------- */

.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.4rem 1rem; }
.legend div { font-size: 0.84rem; color: var(--muted); }
.legend b { color: var(--gold); font-family: var(--mono); margin-right: 0.4rem; }

/* ---------- study placeholder ---------- */

.roadmap { display: flex; flex-direction: column; gap: 0.7rem; }

.roadmap-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.9rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}
.roadmap-item .ico { font-size: 1.3rem; line-height: 1.2; }
.roadmap-item h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.roadmap-item p { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

.status {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .app { padding: 1rem 0.75rem 3rem; }
  .masthead { justify-content: center; text-align: center; }
  .brand .tag { display: none; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; }
}
