:root {
  --bg-top: #eef6ff;
  --bg-bottom: #e7f2eb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #10203a;
  --muted: #5a6a80;
  --line: #d8e3f1;
  --line-strong: #b9c9dd;
  --primary: #0e7a6e;
  --primary-strong: #0b5f56;
  --accent: #f0b429;
  --accent-strong: #cc8b00;
  --ok-bg: #ecfdf3;
  --ok-line: #18a14a;
  --ng-bg: #edf1f6;
  --ng-line: #8ea0b8;
  --shadow-soft: 0 10px 28px rgba(16, 32, 58, 0.08);
  --shadow-card: 0 14px 34px rgba(16, 32, 58, 0.12);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 420px at -8% -15%, rgba(20, 113, 190, 0.15) 0%, rgba(20, 113, 190, 0) 72%),
    radial-gradient(920px 360px at 108% 0%, rgba(14, 122, 110, 0.14) 0%, rgba(14, 122, 110, 0) 66%),
    linear-gradient(155deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  min-height: 100vh;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 26px 16px 44px;
}

.hero {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.86) 0%, rgba(248, 252, 255, 0.98) 60%);
  border: 1px solid rgba(185, 201, 221, 0.68);
  border-radius: 22px;
  padding: 20px 22px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(3px);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.1rem + 1.3vw, 2.2rem);
  letter-spacing: 0.01em;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.panel {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 16px;
  box-shadow: var(--shadow-soft);
}

.start-cta {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.start-simulation-button {
  min-width: 260px;
  min-height: 52px;
  padding: 12px 24px;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  border-radius: 12px;
}

.start-cta-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.control-group.actions {
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(247, 250, 255, 0.92);
  border: 1px solid var(--line);
}

label {
  font-weight: 700;
  color: #193158;
}

select {
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font-weight: 600;
  color: var(--text);
  min-height: 40px;
}

.simulation-count-select {
  min-width: 260px;
  min-height: 96px;
  padding: 20px 16px;
  font-size: 1.2rem;
}

.ticket-stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ticket-stepper strong {
  min-width: 2.2ch;
  text-align: center;
  font-size: 1.05rem;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #f0f4f8 0%, #e0e8f1 100%);
  color: #1a2f4d;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 80ms ease;
  box-shadow: 0 2px 8px rgba(16, 32, 58, 0.12);
}

button:hover {
  transform: none;
  filter: none;
}

button:active {
  transform: translateY(1px) scale(0.99);
  filter: brightness(0.98);
  box-shadow:
    inset 0 2px 4px rgba(16, 32, 58, 0.22),
    0 1px 3px rgba(16, 32, 58, 0.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

button.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
  box-shadow: 0 8px 16px rgba(14, 122, 110, 0.28);
}

button.primary:hover {
  filter: none;
}

button.primary:active {
  transform: translateY(1px) scale(0.99);
  filter: brightness(1.06);
  box-shadow:
    inset 0 2px 4px rgba(7, 51, 46, 0.35),
    0 2px 8px rgba(14, 122, 110, 0.2);
}

.ticket-stepper button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.hint {
  margin-top: 2px;
  color: var(--muted);
}

.ticket-list {
  display: grid;
  gap: 12px;
}

.ticket-list-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.ticket-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--ng-bg);
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.ticket-row.invalid {
  border-color: var(--ng-line);
  background: var(--ng-bg);
}

.ticket-row.valid {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  box-shadow: 0 0 0 1px rgba(24, 161, 74, 0.12), 0 8px 18px rgba(24, 161, 74, 0.12);
}

.ticket-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ticket-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ticket-number {
  font-weight: 800;
  color: #26416b;
  letter-spacing: 0.01em;
}

.ticket-status {
  color: #284974;
  font-size: 0.92rem;
  font-weight: 700;
  min-width: 3ch;
  text-align: right;
}

.ticket-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.ticket-actions button {
  padding: 6px 11px;
  font-size: 0.83rem;
}

.marksheet {
  display: grid;
  grid-template-columns: repeat(11, minmax(34px, 1fr));
  gap: 7px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(243, 248, 255, 0.9) 100%),
    repeating-linear-gradient(
      90deg,
      rgba(145, 165, 194, 0.08) 0,
      rgba(145, 165, 194, 0.08) 1px,
      transparent 1px,
      transparent 24px
    );
}

.number-cell {
  border-radius: 999px;
  border: 1px solid #bcccdc;
  background: #fff;
  padding: 7px 0;
  font-weight: 800;
  font-size: 0.84rem;
  text-align: center;
  color: #2b405f;
}

.number-cell.selected {
  background: linear-gradient(180deg, #ffd067 0%, var(--accent) 100%);
  border-color: var(--accent-strong);
  color: #1f2f45;
  box-shadow: 0 6px 12px rgba(204, 139, 0, 0.28);
}

.number-cell:focus-visible {
  outline: 2px solid #2273d6;
  outline-offset: 1px;
}

.status-row {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.status-row span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
}

.balance-positive {
  color: #15803d;
}

.balance-negative {
  color: #b91c1c;
}

.balance-neutral {
  color: #1a2f4d;
}

.saved-results {
  margin-top: 6px;
}

.saved-result-select {
  min-width: 320px;
  min-height: 42px;
  font-size: 0.95rem;
}

.summary-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.summary-grid > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  box-shadow: 0 6px 14px rgba(16, 32, 58, 0.06);
}

.summary-grid > div strong {
  font-size: 1.06rem;
}

.history-wrap {
  margin-top: 16px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.history-wrap h3 {
  margin: 0;
  color: #1f3b63;
}

.history {
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
  color: #233b5d;
  max-height: 260px;
  overflow-y: auto;
}

.history li {
  line-height: 1.55;
  margin-bottom: 4px;
}

.guide-panel details {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.guide-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: #1f3b63;
}

.guide-content {
  margin-top: 10px;
}

.guide-content h3 {
  margin: 10px 0 6px;
  font-size: 1rem;
  color: #1f3b63;
}

.guide-content ul {
  margin: 0;
  padding-left: 18px;
}

.guide-content li {
  line-height: 1.6;
}

@media (max-width: 900px) {
  .marksheet {
    grid-template-columns: repeat(8, minmax(34px, 1fr));
  }
}

@media (max-width: 740px) {
  .container {
    padding: 18px 12px 30px;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .control-group.actions {
    width: 100%;
  }

  .marksheet {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
  }
}
