:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #697386;
  --paper: #f8f5ef;
  --panel: #ffffff;
  --line: #ded7c8;
  --red: #d94531;
  --gold: #d99a25;
  --green: #177b63;
  --teal: #116d86;
  --shadow: 0 22px 60px rgba(28, 30, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(217, 154, 37, 0.22), transparent 28rem),
    radial-gradient(circle at 92% 18%, rgba(17, 109, 134, 0.18), transparent 24rem),
    linear-gradient(135deg, #fffaf0 0%, #f2f7f4 48%, #f9f2e6 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid rgba(24, 33, 47, 0.08);
  border-radius: 8px;
  color: #fff;
  background-color: #1b2230;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: var(--shadow);
}

.stage::before {
  content: "🥐  🔥";
  position: absolute;
  z-index: 1;
  right: clamp(18px, 4vw, 48px);
  top: clamp(18px, 4vw, 44px);
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(24, 33, 47, 0.28);
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  backdrop-filter: blur(10px);
}

.stage::after {
  content: "";
  position: absolute;
  inset: auto -8% -42% 28%;
  height: 180px;
  transform: rotate(-4deg);
  background: rgba(255, 255, 255, 0.16);
}

.event-mark {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  margin-top: 34px;
}

h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.event-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.event-details p {
  margin: 0;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff7e6;
  background: rgba(24, 33, 47, 0.34);
  font-size: clamp(0.92rem, 1.7vw, 1.08rem);
  font-weight: 850;
}

.subtitle {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.6;
}

.totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(104px, 1fr));
  gap: 10px;
  min-width: 300px;
}

.totals div {
  min-height: 102px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
}

.totals span {
  display: block;
  font-size: 2.3rem;
  font-weight: 900;
}

.totals small {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 700;
}

.control-band {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(28, 30, 38, 0.08);
}

.entry-form {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 112px minmax(248px, auto) minmax(190px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
}

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

label,
legend {
  font-size: 0.9rem;
  font-weight: 800;
}

input[type="number"],
input:not([type]) {
  width: 100%;
  height: 46px;
  border: 1px solid #c9c3b7;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(17, 109, 134, 0.32);
  outline-offset: 2px;
}

.event-picker {
  display: flex;
  gap: 8px;
  align-items: end;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.event-picker legend {
  width: 100%;
  margin-bottom: 7px;
}

.event-picker label {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid #c9c3b7;
  border-radius: 6px;
  background: #fff;
  white-space: nowrap;
}

.event-picker input {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  accent-color: var(--red);
}

.chance-field {
  min-width: 0;
}

.chance-field label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.chance-field strong {
  color: var(--red);
}

.chance-field input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 4px 0 0;
  accent-color: var(--teal);
}

.chance-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.primary-button,
.ghost-button,
.tab,
.icon-button {
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 900;
}

.primary-button {
  min-width: 96px;
  padding: 0 18px;
  color: #fff;
  background: var(--red);
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: #f1ede4;
  border-color: #d7d0c2;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  min-width: 76px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line);
}

.tab.is-active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.status-text {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  text-align: right;
}

.status-text.is-error {
  color: var(--red);
}

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

.entry-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--gold);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 24px rgba(28, 30, 38, 0.08);
}

.entry-card.is-new {
  animation: popIn 680ms cubic-bezier(0.2, 1.2, 0.2, 1);
}

.entry-card.event-bbq {
  border-left-color: var(--green);
}

.entry-card.event-both {
  border-left-color: var(--teal);
}

.entry-badge {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff;
  background: var(--gold);
  font-size: 0.9rem;
  font-weight: 900;
}

.entry-card.event-bbq .entry-badge {
  background: var(--green);
}

.entry-card.event-both .entry-badge {
  background: var(--teal);
  font-size: 0.82rem;
}

.entry-main {
  min-width: 0;
}

.entry-main h2 {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.entry-main p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 900;
}

.entry-actions {
  display: flex;
  gap: 6px;
  grid-column: 2;
  justify-self: end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  color: var(--ink);
  background: #f5f1e8;
  border-color: #ded7c8;
  font-size: 1.2rem;
  line-height: 1;
}

.delete-entry {
  color: var(--red);
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8c0b1;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
  font-weight: 800;
}

.mystery-popup {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 33, 47, 0.46);
  backdrop-filter: blur(8px);
}

.mystery-popup[hidden] {
  display: none;
}

.mystery-card {
  position: relative;
  overflow: hidden;
  width: min(720px, 92vw);
  aspect-ratio: 16 / 9;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background: #000;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  animation: popIn 360ms cubic-bezier(0.2, 1.2, 0.2, 1);
}

.mystery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mystery-card strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  font-size: clamp(4rem, 14vw, 9rem);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.58);
}

.stats-lab {
  position: relative;
  overflow: hidden;
  margin-top: 26px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid rgba(255, 196, 87, 0.24);
  border-radius: 8px;
  color: #f8fbff;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, rgba(217, 69, 49, 0.36), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(17, 109, 134, 0.42), transparent 24rem),
    linear-gradient(135deg, #111827 0%, #1f2630 52%, #171b22 100%);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.28);
}

.stats-lab::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 190, 90, 0.12), transparent);
  transform: translateX(-100%);
  animation: scanLine 5.4s linear infinite;
}

.stats-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.stats-header p {
  margin: 0 0 6px;
  color: #ffca72;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.15rem);
  line-height: 1;
  letter-spacing: 0;
}

.stats-signal {
  display: flex;
  gap: 7px;
  padding-top: 7px;
}

.stats-signal span {
  width: 11px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(#ffd27c, #e44835);
  box-shadow: 0 0 18px rgba(228, 72, 53, 0.72);
  animation: heatPulse 1.4s ease-in-out infinite;
}

.stats-signal span:nth-child(2) {
  height: 46px;
  animation-delay: 180ms;
}

.stats-signal span:nth-child(3) {
  height: 24px;
  animation-delay: 360ms;
}

.stats-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.25fr 0.78fr 1fr;
  gap: 12px;
}

.stat-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(10, 17, 27, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stat-panel-large {
  grid-row: span 2;
}

.stat-panel-wide {
  grid-column: span 2;
}

.stat-label {
  margin-bottom: 12px;
  color: #9fe7e7;
  font-size: 0.86rem;
  font-weight: 950;
  letter-spacing: 0.04em;
}

.expected-number {
  display: flex;
  align-items: end;
  gap: 7px;
  margin-bottom: 12px;
  color: #fff5d7;
  text-shadow: 0 0 24px rgba(255, 202, 114, 0.36);
}

.expected-number span {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 1000;
  line-height: 0.9;
}

.expected-number small {
  margin-bottom: 8px;
  color: #ffca72;
  font-size: 1rem;
  font-weight: 900;
}

.stat-note {
  margin: 12px 0 0;
  color: rgba(248, 251, 255, 0.7);
  font-size: 0.9rem;
  line-height: 1.5;
  font-weight: 750;
}

.person-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 34px;
  padding: 10px;
  border: 1px solid rgba(159, 231, 231, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.person-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 22px;
  height: 30px;
  filter: drop-shadow(0 0 10px rgba(255, 202, 114, 0.32));
}

.person-icon::before,
.person-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fff4d6 0%, #ffba54 58%, #e44835 100%);
}

.person-icon::before {
  top: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.person-icon::after {
  bottom: 0;
  width: 17px;
  height: 17px;
  border-radius: 9px 9px 5px 5px;
}

.person-icon-half {
  clip-path: inset(0 50% 0 0);
}

.person-icon-empty {
  opacity: 0.3;
  filter: none;
}

.person-more {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 202, 114, 0.34);
  border-radius: 999px;
  color: #ffca72;
  font-weight: 950;
}

.heat-ring {
  width: min(176px, 100%);
  aspect-ratio: 1;
  margin: 2px auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #111827 0 48%, transparent 49%),
    conic-gradient(#e44835 var(--heat), rgba(255, 255, 255, 0.12) 0);
  box-shadow: 0 0 34px rgba(228, 72, 53, 0.22);
}

.heat-ring span {
  color: #fff4d6;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 1000;
}

.event-meter + .event-meter {
  margin-top: 16px;
}

.event-meter > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  color: rgba(248, 251, 255, 0.76);
  font-weight: 900;
}

.event-meter strong {
  color: #ffca72;
  font-size: 1.65rem;
}

.meter-track,
.probability-track {
  overflow: hidden;
  height: 11px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meter-track span,
.probability-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9fe7e7, #ffca72, #e44835);
  box-shadow: 0 0 18px rgba(255, 202, 114, 0.34);
  transition: width 380ms ease;
}

.probability-bars {
  display: grid;
  gap: 13px;
}

.probability-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
}

.probability-meta strong {
  color: #fff4d6;
  font-size: 1.15rem;
}

.probability-meta span {
  color: rgba(248, 251, 255, 0.72);
  font-size: 0.88rem;
  font-weight: 850;
  text-align: right;
}

@keyframes scanLine {
  to {
    transform: translateX(100%);
  }
}

@keyframes heatPulse {
  50% {
    transform: scaleY(0.74);
    opacity: 0.62;
  }
}

@keyframes popIn {
  from {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .hero-row,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-panel-large,
  .stat-panel-wide {
    grid-column: 1 / -1;
  }

  .totals {
    width: 100%;
  }

  .event-picker {
    flex-wrap: wrap;
  }

  .form-actions {
    justify-content: stretch;
  }

  .primary-button,
  .ghost-button {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .stage {
    min-height: 250px;
    padding: 24px;
  }

  .totals {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .board-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-text {
    text-align: left;
  }

  .entry-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .entry-actions {
    grid-column: 2;
    justify-content: flex-end;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .probability-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .probability-meta span {
    text-align: left;
  }
}
