:root {
  --bg: #f3f7ff;
  --bg-soft: #ebf2ff;
  --surface: #ffffff;
  --surface-alt: #f8fbff;
  --text: #0f172a;
  --muted: #475569;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-soft: #dbeafe;
  --danger: #c62828;
  --success: #1b8f4d;
  --warning: #d97706;
  --shadow: 0 10px 35px rgba(15, 23, 42, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 12%, #dbeafe 0, #eff6ff 45%, #f8fbff 80%, #f3f7ff 100%);
}

a {
  color: var(--primary);
}

img,
svg {
  max-width: 100%;
  display: block;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.top-nav__title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.muted {
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid #e2e8f0;
  padding: 18px;
}

.card--soft {
  background: linear-gradient(160deg, #ffffff 0%, #f2f7ff 100%);
}

.card h2,
.card h3,
.card h4,
.card p {
  margin-top: 0;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

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

.story-hub {
  margin-top: 16px;
  border-color: #cdddf4;
  background: linear-gradient(160deg, #ffffff 0%, #f3f8ff 100%);
}

.story-hub__header h2 {
  margin-bottom: 6px;
}

.story-hub__header p {
  margin-bottom: 14px;
}

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

.story-link-card {
  text-decoration: none;
  color: inherit;
  display: grid;
  gap: 6px;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid #d5e2f5;
  background: #ffffff;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.story-link-card:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  box-shadow: 0 8px 20px rgba(30, 64, 175, 0.1);
}

.story-link-card strong {
  color: #1e3a8a;
}

.story-link-card p {
  margin: 0;
}

.story-link-card__eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #1d4ed8;
}

.story-page-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 42px;
}

.story-page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  text-decoration: none;
}

.story-page-title {
  margin: 10px 0 6px;
  font-size: clamp(1.6rem, 2.8vw, 2.1rem);
}

.story-page-subtitle {
  margin: 0;
  color: var(--muted);
}

.story-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.story-photo {
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.story-photo figcaption {
  padding: 8px 10px 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.story-photo__img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: linear-gradient(140deg, #e2e8f0 0%, #f8fafc 100%);
}

.story-photo__img--plant {
  filter: contrast(1.04) saturate(0.98);
}

.story-photo__img--control {
  filter: saturate(1.08) hue-rotate(6deg);
}

.story-photo__img--workshop {
  filter: sepia(0.08) contrast(1.03) saturate(1.05);
}

.story-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.story-metric {
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: #fff;
  padding: 11px;
}

.story-metric__label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.story-metric__value {
  margin: 0;
  color: #1e3a8a;
  font-size: 1.26rem;
  font-weight: 800;
}

.story-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.story-tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.story-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f2ff;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 700;
}

.story-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid #dbe4f2;
  padding: 10px 12px;
}

.kpi__label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.kpi__value {
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.progress-track {
  height: 9px;
  width: 100%;
  border-radius: 999px;
  background: #e5edf9;
  overflow: hidden;
  margin-top: 7px;
}

.progress-track > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.progress-track--danger > span {
  background: linear-gradient(90deg, #f97316, #dc2626);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.status-pill--created {
  background: #e2e8f0;
  color: #334155;
}

.status-pill--running {
  background: #dcfce7;
  color: #166534;
}

.status-pill--paused {
  background: #fef3c7;
  color: #92400e;
}

.status-pill--ended {
  background: #fee2e2;
  color: #991b1b;
}

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

label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 10px 11px;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 3px solid rgba(59, 130, 246, 0.2);
  outline-offset: 1px;
}

button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(90deg, #1e40af, #1d4ed8);
}

.btn-ghost {
  background: #dbeafe;
  color: #1e3a8a;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

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

.round-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.round-control__left {
  display: grid;
  gap: 4px;
}

.round-control__right {
  display: flex;
  gap: 8px;
  align-items: center;
}

#round-control-bar {
  position: sticky;
  top: 12px;
  z-index: 20;
  border-color: #bcd4fb;
  background: linear-gradient(160deg, #ffffff 0%, #edf5ff 100%);
}

#round-confirm-btn[disabled] {
  opacity: 0.75;
  cursor: not-allowed;
}

#round-confirm-btn.is-loading {
  background: linear-gradient(90deg, #334155, #1e293b);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.round-guide {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: linear-gradient(160deg, #ffffff 0%, #f3f4ff 100%);
}

.round-guide h3 {
  margin: 0 0 8px;
  color: #312e81;
  font-size: 1rem;
}

.round-guide__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.round-guide__item {
  border: 1px solid #dbe4f2;
  border-radius: 10px;
  background: #ffffff;
  padding: 9px 10px;
}

.round-guide__item strong {
  color: #312e81;
}

.round-guide__item p {
  margin: 4px 0 0;
}

.round-glossary {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: linear-gradient(160deg, #f8fbff 0%, #eef5ff 100%);
}

.round-glossary h3 {
  margin: 0 0 4px;
  color: #1e3a8a;
  font-size: 1rem;
}

.round-glossary .small {
  margin: 0;
}

.round-glossary__list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.round-glossary__item {
  border: 1px solid #dbe4f2;
  border-radius: 10px;
  background: #ffffff;
  padding: 9px 10px;
}

.round-glossary__item strong {
  color: #1e3a8a;
}

.round-glossary__item p {
  margin: 4px 0 0;
}

.briefing-card {
  border-color: #c7d2fe;
  background: linear-gradient(160deg, #ffffff 0%, #eef2ff 100%);
}

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

.briefing-block {
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  padding: 12px;
}

.briefing-block h3 {
  margin: 0 0 8px;
  color: #312e81;
  font-size: 1rem;
}

.briefing-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.briefing-list li::marker {
  color: #1d4ed8;
}

.briefing-list--score li strong {
  color: #1e3a8a;
}

.option-card {
  border: 1px solid #d7e3f6;
  border-radius: 12px;
  padding: 12px;
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.option-card:hover {
  border-color: #93c5fd;
}

.option-card.option-card--selected {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
  transform: translateY(-1px);
}

.option-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.82rem;
}

.option-card strong {
  color: #1e3a8a;
}

.option-card__summary {
  margin-top: -2px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
}

th {
  color: #1e3a8a;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.rank-top {
  background: #eef5ff;
}

.podium-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.podium-card {
  border: 1px solid #dbe4f2;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffffff 0%, #f8fbff 100%);
  padding: 14px;
}

.podium-card--winner {
  border-color: #93c5fd;
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.12);
}

.podium-card__place {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e0ecff;
  color: #1e3a8a;
  font-size: 0.78rem;
  font-weight: 800;
}

.podium-card__name {
  margin: 10px 0 4px;
  font-size: 1.05rem;
}

.podium-card__score {
  margin: 0 0 8px;
  color: #1d4ed8;
  font-size: 1.45rem;
  font-weight: 800;
}

.podium-card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

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

.award-card {
  border: 1px solid #dbe4f2;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffffff 0%, #f8fbff 100%);
  padding: 14px;
}

.award-card__label {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9efff;
  color: #1e3a8a;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.award-card__title {
  margin: 10px 0 4px;
  font-size: 1rem;
  color: #0f172a;
}

.award-card__winner {
  margin: 0 0 5px;
  color: #1d4ed8;
  font-size: 1.2rem;
  font-weight: 800;
}

.award-card__metric {
  margin: 0 0 7px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 700;
}

.award-card__description {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.feed-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.feed-item {
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px;
}

.feed-item__title {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.feed-item__meta {
  font-size: 0.8rem;
  color: var(--muted);
}

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

.avatar-btn {
  border: 1px solid #cbd5e1;
  background: #f8fbff;
  border-radius: 10px;
  padding: 8px;
}

.avatar-btn.active {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.18);
}

.avatar-svg {
  width: 78px;
  margin: 0 auto 6px;
}

.avatar-david {
  width: min(230px, 100%);
  margin: 0 auto;
}

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 0.9rem;
}

.notice.notice--danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

.notice.notice--success {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

#waiting-card {
  border-color: #bfdbfe;
  background: linear-gradient(160deg, #ffffff 0%, #eef5ff 100%);
}

body.player-connected #player-main-card .hero {
  grid-template-columns: 1fr;
  gap: 8px;
}

body.player-connected #player-main-card #player-david-avatar {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal.open {
  display: grid;
}

.modal__panel {
  width: min(500px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.35);
}

.small {
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

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

  .briefing-grid,
  .podium-grid,
  .award-grid,
  .option-grid,
  .kpi-strip,
  .story-links,
  .story-photo-grid,
  .story-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 700px) {
  .round-control {
    flex-direction: column;
    align-items: stretch;
  }

  .round-control__right {
    width: 100%;
  }

  .round-control__right > button {
    width: 100%;
  }

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

  .round-glossary__list,
  .round-guide__grid,
  .briefing-grid,
  .podium-grid,
  .award-grid,
  .option-grid,
  .kpi-strip,
  .avatar-grid,
  .story-links,
  .story-photo-grid,
  .story-metric-grid {
    grid-template-columns: 1fr;
  }

  .top-nav {
    flex-direction: column;
    align-items: flex-start;
  }
}
