:root {
  --bg: #20110d;
  --panel: rgba(42, 20, 15, 0.86);
  --panel-soft: rgba(255, 246, 236, 0.08);
  --card: #fff8f0;
  --ink: #1f1712;
  --text: #f8eee3;
  --muted: rgba(248, 238, 227, 0.72);
  --line: rgba(255, 235, 214, 0.12);
  --accent: #ef5f2f;
  --accent-2: #ffbf47;
  --positive: #19764d;
  --negative: #b83c2f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Outfit", sans-serif;
  background:
    radial-gradient(circle at 20% 20%, rgba(239, 95, 47, 0.3), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(255, 191, 71, 0.16), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(239, 95, 47, 0.18), transparent 28%),
    linear-gradient(180deg, #130908 0%, #28120d 52%, #1a0d09 100%);
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(60px);
  pointer-events: none;
  opacity: 0.5;
}

.ambient-a {
  top: 40px;
  left: -80px;
  width: 260px;
  height: 260px;
  background: rgba(255, 191, 71, 0.24);
}

.ambient-b {
  right: -40px;
  bottom: 40px;
  width: 300px;
  height: 300px;
  background: rgba(239, 95, 47, 0.22);
}

.app-shell {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.auth-screen {
  min-height: calc(100vh - 72px);
  display: none;
  place-items: center;
}

.auth-screen.active {
  display: grid;
}

.auth-card {
  width: min(100%, 520px);
  padding: 36px 24px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.hero-screen {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
}

.hero-stage,
.setup-screen,
.battle-panel,
.battle-summary {
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-stage {
  width: min(100%, 980px);
  padding: 64px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-stage::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 235, 214, 0.12);
  border-radius: 24px;
  pointer-events: none;
}

.hero-stage > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-2);
}

.topbar,
.setup-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h1,
h2,
h3 {
  font-family: "Noto Serif SC", serif;
}

h1 {
  margin: 10px 0 16px;
  font-size: clamp(3rem, 9vw, 6.4rem);
  line-height: 0.98;
}

h2 {
  margin: 8px 0 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.hero-copy {
  max-width: 700px;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.hero-note {
  margin-top: 18px;
  color: var(--muted);
}

.hero-button,
.primary-btn,
.ghost-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.hero-button {
  min-width: min(100%, 420px);
  padding: 24px 32px;
  border-radius: 999px;
  color: #fff9f1;
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #b8361e 58%, #8f2412 100%);
  box-shadow:
    0 22px 60px rgba(239, 95, 47, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.hero-button:hover,
.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-2px);
}

.ghost-btn {
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.danger-btn {
  background: rgba(184, 60, 47, 0.22);
  color: #ffd8d1;
}

.setup-screen,
.battle-screen {
  display: none;
}

.setup-screen.active,
.battle-screen.active {
  display: block;
}

.setup-screen,
.battle-screen .battle-panel,
.battle-screen .battle-summary {
  padding: 26px;
}

.section-head,
.battle-header,
.battle-top-row,
.action-row,
.score-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head,
.battle-header {
  margin-bottom: 22px;
}

.section-head.compact {
  margin-bottom: 18px;
}

.time-chip,
.chip-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.92rem;
}

.setup-form,
.battle-form {
  display: grid;
  gap: 18px;
}

.player-name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setup-row,
.battle-top-row,
.score-grid {
  display: grid;
  gap: 16px;
}

.setup-row,
.battle-top-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.battle-top-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 241, 227, 0.1);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: rgba(248, 238, 227, 0.38);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(255, 191, 71, 0.45);
  box-shadow: 0 0 0 4px rgba(255, 191, 71, 0.12);
}

textarea {
  resize: vertical;
}

.primary-btn {
  justify-self: end;
  padding: 14px 24px;
  border-radius: 999px;
  color: #fff9f1;
  background: linear-gradient(135deg, var(--accent), #b8361e);
  box-shadow: 0 18px 40px rgba(239, 95, 47, 0.22);
}

.battle-screen {
  display: none;
  gap: 18px;
}

.battle-screen.active {
  display: grid;
}

.battle-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.battle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.battle-meta > * {
  flex-shrink: 0;
}

.balance-tip {
  padding: 14px 16px;
  border: 1px solid rgba(255, 191, 71, 0.18);
  border-radius: 20px;
  background: rgba(255, 191, 71, 0.08);
  color: #ffd790;
  line-height: 1.7;
}

.score-card,
.summary-card,
.history-card,
.segment-row {
  border: 1px solid rgba(255, 241, 227, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.06);
}

.score-card {
  padding: 18px;
}

.score-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.player-preview {
  margin: 12px 0 0;
  color: var(--muted);
}

.battle-summary {
  margin-top: 18px;
}

.summary-card,
.history-card,
.segment-row {
  padding: 18px;
}

.summary-meta,
.history-meta,
.segment-meta,
.result-line,
.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.segment-breakdown {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.summary-meta,
.history-meta,
.segment-meta {
  margin-bottom: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  font-size: 0.88rem;
}

.segment-index-tag {
  padding: 9px 15px;
  font-size: 1.06rem;
  font-weight: 700;
  color: #fff7ef;
  background: linear-gradient(135deg, rgba(239, 95, 47, 0.58), rgba(184, 60, 47, 0.42));
  border: 1px solid rgba(255, 191, 71, 0.24);
}

.totals {
  margin-bottom: 16px;
}

.stat {
  min-width: 180px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 248, 240, 0.92);
  color: var(--ink);
}

.stat label {
  color: #78695d;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
}

.positive {
  color: var(--positive);
  font-weight: 700;
}

.negative {
  color: var(--negative);
  font-weight: 700;
}

.history-list,
#summary-content,
.today-total {
  display: grid;
  gap: 14px;
}

.empty-state {
  padding: 22px;
  border: 1px dashed rgba(255, 241, 227, 0.16);
  border-radius: 22px;
  color: var(--muted);
  text-align: center;
}

.error-text {
  min-height: 22px;
  margin: 14px 0 0;
  color: #ff8d7d;
}

@media (max-width: 920px) {
  .player-name-grid,
  .setup-row,
  .battle-top-row,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .battle-header,
  .score-card-top,
  .topbar,
  .setup-actions,
  .summary-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .battle-meta {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px 12px 28px;
  }

  .hero-stage,
  .setup-screen,
  .battle-panel,
  .battle-summary {
    padding: 18px;
    border-radius: 24px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .hero-button,
  .primary-btn {
    width: 100%;
  }

  .primary-btn {
    justify-self: stretch;
  }

  .ghost-btn,
  .ghost-link,
  .time-chip,
  .chip-pill {
    width: 100%;
    justify-content: center;
  }

  .battle-meta > * {
    width: 100%;
  }

  .history-card,
  .summary-card,
  .segment-row,
  .score-card {
    padding: 16px;
  }

  .result-line,
  .summary-meta,
  .history-meta,
  .segment-meta,
  .totals {
    gap: 8px;
  }
}
