:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --panel: #ffffff;
  --ink: #17211e;
  --muted: #63716c;
  --line: #dbe3df;
  --green: #0f7b62;
  --green-dark: #095a49;
  --gold: #c99529;
  --gold-soft: #fff5d8;
  --blue: #315da8;
  --blue-soft: #eef4ff;
  --red: #b94b44;
  --soft: #f7faf8;
  --shadow: 0 18px 55px rgba(24, 44, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(15, 123, 98, 0.14), transparent 30%),
    linear-gradient(135deg, #f7f5ef 0%, var(--bg) 42%, #eef5f1 100%);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1880px, calc(100% - 18px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 14px;
  display: grid;
  gap: 20px;
}

.sim-language-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -10px;
}

.language-control {
  min-width: 180px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 850;
}

.language-control select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
}

.app-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.user-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.backend-pill {
  min-height: 28px;
  border: 1px solid rgba(15, 123, 98, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 900;
}

.backend-pill.is-cloud {
  border-color: rgba(15, 123, 98, 0.32);
  background: #eef8f4;
  color: var(--green-dark);
}

.backend-pill.is-local {
  border-color: rgba(201, 149, 41, 0.32);
  background: var(--gold-soft);
  color: #8a651b;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
}

h2 {
  font-size: 20px;
}

.page-tabs {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.tab-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 850;
}

.tab-button.active {
  border-color: rgba(15, 123, 98, 0.22);
  background: #fff;
  color: var(--green-dark);
  box-shadow: 0 8px 22px rgba(24, 44, 38, 0.08);
}

.inline-link-button {
  min-height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--green-dark);
  padding: 0 6px;
  font-size: 13px;
  font-weight: 850;
}

.inline-link-button:hover {
  background: rgba(15, 123, 98, 0.08);
}

.profile-card,
.admin-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 227, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.profile-card {
  width: min(820px, 100%);
  margin: 0 auto;
}

.profile-header,
.admin-panel > header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.profile-header p {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.profile-actions {
  display: grid;
  gap: 10px;
  min-width: 160px;
}

.profile-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.mode-button {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
}

.mode-button.active {
  background: var(--green);
  color: #fff;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin-top: 22px;
}

.profile-submit {
  width: 100%;
  min-height: 56px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
}

.small-button.danger {
  background: #fff;
  color: var(--red);
  border-color: rgba(185, 75, 68, 0.28);
}

.admin-panel {
  border-color: rgba(49, 93, 168, 0.24);
}

.admin-lock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.admin-content {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.admin-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-table-wrap {
  display: grid;
  gap: 12px;
}

.admin-table-wrap h3 {
  margin: 0;
  font-size: 18px;
}

.admin-player-rows {
  display: grid;
  gap: 9px;
  max-height: 280px;
  overflow: auto;
}

.admin-player-row {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.admin-player-row strong,
.admin-player-row span {
  display: block;
}

.admin-player-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.admin-player-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-player-stats span {
  border-radius: 999px;
  background: var(--soft);
  padding: 5px 9px;
  margin: 0;
  color: var(--ink);
  font-weight: 850;
}

.page[hidden] {
  display: none;
}

.draw-page {
  display: grid;
  grid-template-columns: minmax(220px, 0.68fr) minmax(0, 2.25fr) minmax(250px, 0.82fr);
  gap: 20px;
  align-items: start;
}

.draw-wide {
  grid-column: 1 / -1;
}

.side-stack {
  display: grid;
  gap: 20px;
}

.inventory-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.ticket-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.sim-panel,
.pool-card,
.rules-card,
.stats-card,
.a-stats-card,
.ovr-card,
.inventory-panel,
.fragment-card,
.spend-banner,
.ticket-panel,
.ticket-history-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(219, 227, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sim-panel {
  min-height: calc(100vh - 104px);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pool-card,
.rules-card,
.stats-card,
.a-stats-card,
.ovr-card,
.inventory-panel,
.fragment-card,
.ticket-panel,
.ticket-history-panel {
  padding: 18px;
}

.spend-banner {
  min-height: 132px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
  align-items: center;
  border-color: rgba(185, 75, 68, 0.28);
  background:
    linear-gradient(90deg, rgba(255, 238, 234, 0.96), rgba(255, 255, 255, 0.96) 48%),
    #fff;
  position: relative;
  overflow: hidden;
}

.spend-banner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: var(--red);
}

.spend-banner-copy {
  padding-left: 8px;
}

.spend-banner-copy h2 {
  color: var(--red);
  font-size: clamp(24px, 3vw, 36px);
}

.spend-banner-copy p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.spend-metrics,
.ticket-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.spend-metric,
.ticket-summary-grid div {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 5px;
}

.spend-metric.primary {
  border-color: rgba(15, 123, 98, 0.32);
  background: #eef8f4;
}

.spend-metric span,
.ticket-summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.spend-metric strong,
.ticket-summary-grid strong {
  color: var(--ink);
  font-size: clamp(22px, 2.6vw, 31px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.spend-metric.primary strong {
  color: var(--green-dark);
}

.developer-badge {
  grid-column: 1 / -1;
  margin: -4px 0 0;
  border: 1px solid rgba(49, 93, 168, 0.22);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 900;
}

.ticket-panel {
  min-height: calc(100vh - 120px);
}

.ticket-header p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.5;
}

.ticket-summary-grid {
  margin-top: 16px;
}

.ticket-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.ticket-card {
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.ticket-card header,
.ticket-history-panel header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.ticket-card h3,
.ticket-history-panel h2 {
  margin: 0;
}

.ticket-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 750;
}

.daily-ticket-card {
  border-color: rgba(15, 123, 98, 0.28);
  background: linear-gradient(180deg, #eef8f4, #fff 68%);
}

.developer-ticket-card {
  border-color: rgba(49, 93, 168, 0.24);
  background: linear-gradient(180deg, var(--blue-soft), #fff 70%);
}

.poem-ticket-card {
  grid-column: 1 / -1;
  border-color: rgba(201, 149, 41, 0.34);
  background: linear-gradient(180deg, var(--gold-soft), #fff 72%);
}

.large-countdown {
  min-height: 64px;
  border-radius: 8px;
  background: #fff;
  color: var(--red);
  display: grid;
  place-items: center;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
}

.poem-question {
  border: 1px solid rgba(201, 149, 41, 0.34);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.poem-question span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.poem-question strong {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.25;
}

.ticket-button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.4fr);
  gap: 10px;
}

.small-button.calm {
  color: var(--green-dark);
  border-color: var(--line);
}

.ticket-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ticket-history-panel {
  position: sticky;
  top: 18px;
}

.ticket-history-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.ticket-history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  display: grid;
  gap: 4px;
}

.ticket-history-item strong {
  font-size: 18px;
}

.ticket-history-item strong.positive {
  color: var(--green-dark);
}

.ticket-history-item strong.negative {
  color: var(--red);
}

.ticket-history-item span,
.ticket-history-item small {
  color: var(--muted);
}

.topbar,
.pool-card header,
.rules-card header,
.stats-card header,
.a-stats-card header,
.ovr-card header,
.fragment-card header,
.inventory-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green-dark);
  font-size: 24px;
  line-height: 1;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.activity-field {
  grid-column: 1;
}

.group-field {
  grid-column: 1;
}

.field {
  display: grid;
  gap: 7px;
}

.field.compact {
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.group-field select {
  min-height: 58px;
  border-color: rgba(15, 123, 98, 0.42);
  box-shadow: inset 0 0 0 1px rgba(15, 123, 98, 0.08);
  font-size: 18px;
  font-weight: 850;
}

.group-summary {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field input:focus,
.field select:focus,
.draw-button:focus,
.icon-button:focus,
.small-button:focus,
.tile-action:focus,
.row-action:focus,
.score-band-action:focus,
.reveal-close:focus,
.reveal-next:focus,
.tab-button:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 123, 98, 0.15);
}

.rule-strip {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rule-strip div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.rule-strip span,
.rule-strip small {
  color: var(--muted);
}

.rule-strip strong {
  font-size: 24px;
}

.guarantee-stack {
  display: grid;
  gap: 10px;
}

.pity-card {
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(15, 123, 98, 0.22);
  background: #eef8f4;
}

.main-pity {
  min-height: 148px;
}

.bplus-card {
  border-color: rgba(49, 93, 168, 0.22);
  background: var(--blue-soft);
  padding: 12px 14px;
}

.pity-main,
.minor-pity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pity-main span {
  color: var(--muted);
  font-weight: 800;
}

.pity-main strong {
  font-size: 40px;
  color: var(--green-dark);
}

.bplus-card .pity-main strong {
  color: var(--blue);
}

.minor-pity-row strong {
  display: block;
  color: var(--blue);
  font-size: 16px;
}

.minor-pity-row span {
  min-width: 44px;
  min-height: 36px;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
}

.pity-track {
  height: 12px;
  margin: 12px 0 10px;
  border-radius: 999px;
  background: rgba(9, 90, 73, 0.12);
  overflow: hidden;
}

.bplus-card .pity-track {
  background: rgba(49, 93, 168, 0.13);
}

.pity-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 180ms ease;
}

.bplus-fill {
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.pity-card p {
  margin: 0;
  color: var(--muted);
}

.bplus-card p {
  font-size: 13px;
}

.draw-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.draw-button {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 850;
}

.draw-button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.draw-button.ghost {
  color: var(--blue);
}

.real-entry-callout {
  min-height: 46px;
  border: 1px solid rgba(15, 109, 89, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.real-entry-link {
  min-height: 34px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.result-stage {
  flex: 1;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-height: 500px;
}

.latest-result {
  min-height: 180px;
  padding: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  align-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.latest-result::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: var(--line);
}

.latest-result.tier-A::before {
  background: var(--gold);
}

.latest-result.tier-B::before {
  background: var(--blue);
}

.latest-result.tier-C::before {
  background: var(--green);
}

.latest-result.empty::before {
  background: var(--line);
}

.result-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.latest-result strong {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.08;
}

.latest-result small {
  color: var(--muted);
  font-size: 14px;
}

.run-report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.run-report.complete {
  border-color: rgba(201, 149, 41, 0.42);
  background: linear-gradient(90deg, var(--gold-soft), #fff 44%);
}

.run-report header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.run-report header strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.report-prefill-button {
  min-height: 36px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.run-report p {
  margin: 0;
  color: var(--muted);
}

.run-report-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.run-report-grid div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.run-report-grid span {
  color: var(--muted);
  font-size: 12px;
}

.run-report-grid strong {
  font-size: 22px;
}

.draw-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.draw-tile {
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 5px;
  align-content: start;
}

.draw-tile strong {
  font-size: 24px;
}

.draw-tile span,
.draw-tile small {
  color: var(--muted);
}

.draw-tile.tier-A {
  border-color: rgba(201, 149, 41, 0.55);
  background: linear-gradient(180deg, var(--gold-soft), #ffffff 72%);
}

.draw-tile.tier-B {
  border-color: rgba(49, 93, 168, 0.35);
  background: linear-gradient(180deg, var(--blue-soft), #ffffff 76%);
}

.draw-tile.tier-A strong {
  color: var(--gold);
}

.draw-tile.tier-B strong {
  color: var(--blue);
}

.draw-tile.tier-C strong {
  color: var(--green);
}

.tile-action,
.row-action,
.small-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green-dark);
  font-weight: 800;
  font-size: 13px;
}

.tile-action {
  margin-top: 4px;
  width: 100%;
}

.small-button {
  min-height: 42px;
  padding: 0 12px;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.small-button.secondary {
  width: 100%;
  margin-top: 12px;
  background: #fff;
  color: var(--red);
  border-color: rgba(185, 75, 68, 0.28);
}

.admin-dock {
  display: flex;
  justify-content: flex-end;
  min-height: 28px;
}

.quiet-admin-button {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: rgba(99, 113, 108, 0.72);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
}

.quiet-admin-button:hover,
.quiet-admin-button:focus {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
}

.pool-players {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.pool-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.player-row {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
}

.player-row strong {
  flex: 0 0 auto;
}

.player-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  text-align: right;
}

.ovr-badge {
  min-width: 42px;
  border-radius: 999px;
  padding: 3px 8px;
  text-align: center;
  color: #fff;
  font-weight: 850;
}

.ovr-badge.ovr-120 {
  background: var(--gold);
}

.ovr-badge.ovr-119 {
  background: var(--blue);
}

.ovr-badge.ovr-118 {
  background: var(--green);
}

.ovr-badge.ovr-117,
.ovr-badge.ovr-116,
.ovr-badge.ovr-115 {
  background: var(--blue);
}

.stats-grid,
.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.score-grid.compact {
  grid-template-columns: repeat(3, 1fr);
}

.stats-grid div,
.score-item {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.score-item {
  min-height: 58px;
}

.stats-grid span,
.score-item span {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong,
.score-item strong {
  font-size: 24px;
}

.inventory-panel {
  min-height: calc(100vh - 120px);
}

.sort-field {
  min-width: 180px;
}

.inventory-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.inventory-summary div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.inventory-summary span {
  color: var(--muted);
  font-size: 13px;
}

.inventory-summary strong {
  font-size: 22px;
}

.score-bands {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.score-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.score-band.tier-A {
  border-color: rgba(201, 149, 41, 0.42);
  background: linear-gradient(90deg, var(--gold-soft), #fff 34%);
}

.score-band.tier-B {
  border-color: rgba(49, 93, 168, 0.3);
  background: linear-gradient(90deg, var(--blue-soft), #fff 34%);
}

.score-band header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-band-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-band-title strong {
  min-width: 54px;
  min-height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-size: 24px;
}

.score-band.tier-A .score-band-title strong {
  background: var(--gold);
}

.score-band.tier-B .score-band-title strong {
  background: var(--blue);
}

.score-band-title span,
.score-band-stats small,
.inventory-player span {
  color: var(--muted);
}

.score-band-stats {
  text-align: right;
  display: grid;
  gap: 3px;
  justify-items: end;
}

.score-band-stats span {
  font-size: 20px;
  font-weight: 900;
}

.inventory-player-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 8px;
}

.inventory-player {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.inventory-player strong {
  display: block;
  overflow-wrap: anywhere;
}

.inventory-player span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.row-action {
  min-width: 0;
  padding: 0 10px;
}

.score-band-action {
  min-height: 30px;
  border: 1px solid rgba(15, 123, 98, 0.22);
  border-radius: 8px;
  background: #fff;
  color: var(--green-dark);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.fragment-card {
  position: sticky;
  top: 18px;
}

.fragment-total {
  min-height: 82px;
  border: 1px solid rgba(201, 149, 41, 0.35);
  border-radius: 8px;
  background: var(--gold-soft);
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 4px;
  margin-top: 14px;
}

.fragment-total span {
  color: var(--muted);
  font-weight: 800;
}

.fragment-total strong {
  font-size: 32px;
}

.manual-fragment {
  display: grid;
  grid-template-columns: 1.25fr 0.8fr;
  gap: 10px;
  margin-top: 12px;
}

.manual-fragment .small-button {
  grid-column: 1 / -1;
}

.fragment-list {
  display: grid;
  gap: 9px;
  max-height: 470px;
  margin-top: 14px;
  overflow: auto;
  padding-right: 4px;
}

.fragment-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  display: grid;
  gap: 8px;
}

.fragment-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fragment-row-main span {
  color: var(--muted);
  text-align: right;
}

.fragment-names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fragment-names em {
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 4px 8px;
  font-style: normal;
  font-size: 12px;
}

.empty-note {
  margin: 0;
  color: var(--muted);
}

.reveal-modal[hidden] {
  display: none;
}

.reveal-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  cursor: pointer;
}

.reveal-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(8, 13, 20, 0.82), rgba(10, 29, 37, 0.78)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 18px);
  backdrop-filter: blur(9px);
}

.reveal-panel {
  width: min(430px, calc(100vw - 28px));
  min-height: min(700px, calc(100vh - 28px));
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: opacity 160ms ease, transform 160ms ease;
}

.reveal-modal.is-visible .reveal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.reveal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.reveal-next {
  position: relative;
  z-index: 3;
  min-width: 128px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #17211e;
  font-weight: 900;
}

.reveal-light {
  position: absolute;
  width: min(640px, 140vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0deg, rgba(255, 230, 149, 0.32) 24deg, transparent 52deg, rgba(66, 140, 255, 0.22) 78deg, transparent 118deg, rgba(255, 255, 255, 0.28) 146deg, transparent 190deg, rgba(255, 213, 92, 0.2) 226deg, transparent 280deg, rgba(255, 255, 255, 0.18) 310deg, transparent 360deg);
  filter: blur(1px);
  opacity: 0;
  animation: revealLightSpin 1800ms ease-out forwards;
  pointer-events: none;
}

.reveal-card {
  width: min(310px, calc(100vw - 58px));
  aspect-ratio: 0.72;
  position: relative;
  border-radius: 8px;
  padding: 10px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), transparent 28%),
    linear-gradient(160deg, #1b3158 0%, #0f1a30 48%, #09111f 100%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.44),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transform-origin: center;
  animation: revealCardFlip 1180ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  cursor: pointer;
}

.reveal-card.tier-A {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.3), transparent 28%),
    linear-gradient(160deg, #a86f13 0%, #242014 52%, #110d08 100%);
}

.reveal-card::before {
  content: "";
  position: absolute;
  inset: -30% -70%;
  background: linear-gradient(105deg, transparent 34%, rgba(255, 255, 255, 0.58) 48%, transparent 62%);
  transform: translateX(-56%);
  animation: revealCardSheen 1180ms ease-out forwards;
}

.reveal-card::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  pointer-events: none;
}

.reveal-card-inner {
  height: 100%;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 16px;
}

.reveal-card:not(.reveal-stage-player) .reveal-card-inner {
  grid-template-rows: 1fr;
  align-items: center;
}

.reveal-card:not(.reveal-stage-player) .reveal-card-top,
.reveal-card:not(.reveal-stage-player) .reveal-card-bottom {
  display: none;
}

.reveal-card-top,
.reveal-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reveal-card-top span,
.reveal-card-bottom span,
.reveal-meta,
.reveal-batch-note {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
}

.reveal-card-top strong {
  font-size: 46px;
  line-height: 1;
  color: #fff4c0;
  text-shadow: 0 3px 18px rgba(255, 207, 75, 0.32);
}

.reveal-card-center {
  min-height: 0;
  display: grid;
  place-items: center;
  gap: 12px;
}

.reveal-stage-label {
  min-height: 28px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 18px;
  font-weight: 950;
}

.reveal-stage-player .reveal-stage-label {
  display: none;
}

.reveal-card:not(.reveal-stage-player) .reveal-card-center {
  align-content: center;
  gap: 22px;
}

.reveal-card:not(.reveal-stage-player) .reveal-flag,
.reveal-card:not(.reveal-stage-player) .reveal-position,
.reveal-card:not(.reveal-stage-player) .reveal-team-shield {
  display: none;
  margin-top: 0;
}

.reveal-card.reveal-stage-flag .reveal-flag,
.reveal-card.reveal-stage-position .reveal-position,
.reveal-card.reveal-stage-team .reveal-team-shield {
  display: grid;
  animation: revealPartPop 320ms ease-out both;
}

.reveal-flag {
  width: 128px;
  height: 90px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  font-size: 60px;
  box-shadow: inset 0 0 26px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.reveal-flag img,
.reveal-position img,
.reveal-team-shield img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  grid-area: 1 / 1;
}

.reveal-flag span,
.reveal-position span,
.reveal-team-shield span {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
}

.reveal-flag img:not([hidden]) + span,
.reveal-position img:not([hidden]) + span,
.reveal-team-shield img:not([hidden]) + span {
  display: none;
}

.reveal-team-shield {
  width: 82px;
  height: 92px;
  margin-top: -22px;
  clip-path: polygon(50% 0, 96% 18%, 88% 76%, 50% 100%, 12% 76%, 4% 18%);
  background: linear-gradient(180deg, #fff7c7, #b98929 54%, #5a3a10);
  color: #16211e;
  display: grid;
  place-items: center;
  font-size: 21px;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.reveal-stage-team .reveal-team-shield {
  width: 132px;
  height: 148px;
  font-size: 32px;
}

.reveal-position {
  min-width: 70px;
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
  overflow: visible;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.36);
}

.reveal-stage-position .reveal-position {
  min-width: 132px;
  min-height: 86px;
  font-size: 58px;
}

.reveal-card-bottom {
  align-items: end;
}

.reveal-card-bottom strong {
  min-width: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.reveal-card-bottom span {
  text-align: right;
}

.reveal-meta,
.reveal-batch-note {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
}

.reveal-batch-note {
  min-height: 18px;
}

.reveal-progress {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.reveal-progress span {
  width: 30px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.reveal-progress span.active {
  background: #fff4c0;
}

@keyframes revealLightSpin {
  0% {
    opacity: 0;
    transform: rotate(0deg) scale(0.55);
  }
  26% {
    opacity: 1;
  }
  100% {
    opacity: 0.36;
    transform: rotate(145deg) scale(1);
  }
}

@keyframes revealCardFlip {
  0% {
    opacity: 0;
    transform: perspective(900px) rotateY(86deg) scale(0.64);
  }
  42% {
    opacity: 1;
    transform: perspective(900px) rotateY(-10deg) scale(1.06);
  }
  72% {
    transform: perspective(900px) rotateY(4deg) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: perspective(900px) rotateY(0) scale(1);
  }
}

@keyframes revealCardSheen {
  0% {
    transform: translateX(-58%);
    opacity: 0;
  }
  36% {
    opacity: 1;
  }
  100% {
    transform: translateX(58%);
    opacity: 0;
  }
}

@keyframes revealPartPop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.84);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-light,
  .reveal-card,
  .reveal-card::before {
    animation: none;
  }

  .reveal-panel,
  .pity-fill {
    transition: none;
  }
}

@media (max-width: 1180px) {
  .draw-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .spend-banner,
  .ticket-page {
    grid-template-columns: 1fr;
  }

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

  .left-stack {
    order: 2;
  }

  .sim-panel {
    order: 1;
    min-height: auto;
  }

  .right-stack {
    order: 3;
  }

  .rule-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .inventory-page {
    grid-template-columns: 1fr;
  }

  .fragment-card {
    position: static;
  }

  .ticket-history-panel {
    position: static;
  }

  .spend-metrics,
  .ticket-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inventory-player-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1380px);
    padding: 16px 0;
  }

  .app-header,
  .profile-header,
  .admin-panel > header,
  .inventory-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .sim-panel,
  .pool-card,
  .rules-card,
  .stats-card,
  .a-stats-card,
  .ovr-card,
  .inventory-panel,
  .fragment-card,
  .spend-banner,
  .ticket-panel,
  .ticket-history-panel {
    padding: 14px;
  }

  .control-band,
  .guarantee-stack,
  .draw-actions,
  .side-stack,
  .rule-strip,
  .inventory-summary,
  .spend-metrics,
  .ticket-summary-grid,
  .ticket-method-grid,
  .ticket-button-row,
  .profile-form,
  .admin-lock,
  .admin-settings {
    grid-template-columns: 1fr;
  }

  .profile-actions,
  .header-actions {
    justify-items: stretch;
  }

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

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

  .latest-result {
    min-height: 120px;
  }

  .reveal-panel {
    min-height: calc(100vh - 24px);
  }

  .reveal-card {
    width: min(286px, calc(100vw - 48px));
  }

  .reveal-flag {
    width: 112px;
    height: 78px;
    font-size: 52px;
  }
}

@media (max-width: 460px) {
  .draw-grid,
  .run-report-grid,
  .stats-grid,
  .score-grid.compact,
  .manual-fragment {
    grid-template-columns: 1fr;
  }

  .score-band header,
  .inventory-player,
  .fragment-row-main {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .score-band-stats,
  .fragment-row-main span {
    text-align: left;
  }

  .row-action {
    width: 100%;
  }
}
