:root {
  color-scheme: light;
  --ink: #17232a;
  --muted: #56666d;
  --paper: #fffefa;
  --canvas: #edf4f1;
  --navy: #123c4a;
  --teal: #08756d;
  --teal-dark: #045850;
  --lime: #1d9a64;
  --lime-pale: #e4f7eb;
  --yellow: #f2bd40;
  --yellow-pale: #fff6d9;
  --coral: #ad4938;
  --coral-pale: #fff0eb;
  --line: #ccdbd8;
  --shadow: 0 14px 32px rgba(21, 57, 63, .12);
  --radius: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 9% 2%, rgba(242, 189, 64, .24) 0 9px, transparent 10px),
    radial-gradient(circle at 94% 19%, rgba(8, 117, 109, .12) 0 72px, transparent 73px),
    linear-gradient(180deg, #f9fbf7 0, var(--canvas) 100%);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  padding: .72rem 1.05rem;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.3;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

button:hover:not(:disabled) {
  background: var(--teal-dark);
  box-shadow: 0 6px 14px rgba(4, 88, 80, .18);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  background: #dce5e4;
  color: #627277;
}

button.secondary {
  background: var(--paper);
  border-color: #9bbab3;
  color: var(--teal-dark);
}

button.secondary:hover:not(:disabled) { background: #e7f3ef; }
button.secondary:disabled { color: #68767b; background: #e7eceb; }

button:focus-visible, input:focus-visible, a:focus-visible, main:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.page {
  max-width: 1180px;
  margin: auto;
  padding: 42px 28px 34px;
}

.page-header {
  position: relative;
  overflow: hidden;
  padding: 27px 30px 31px;
  border: 1px solid #a9cbc4;
  border-radius: 28px;
  background: linear-gradient(115deg, #e1f3ec, #f9fcf6 66%);
  box-shadow: var(--shadow);
}

.page-header::after {
  content: "⚗";
  position: absolute;
  right: 26px;
  bottom: -34px;
  color: rgba(8, 117, 109, .13);
  font-size: 11rem;
  line-height: 1;
  pointer-events: none;
}

.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: .74rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  max-width: 750px;
  margin-bottom: 12px;
  color: var(--navy);
  font-size: clamp(2.3rem, 6vw, 4.1rem);
  letter-spacing: -.055em;
  line-height: 1;
}

h2 { margin-bottom: 6px; font-size: 1.2rem; }

h3 {
  margin: 16px 0 10px;
  color: var(--navy);
  font-size: 1.26rem;
  line-height: 1.25;
}

.intro {
  max-width: 700px;
  margin-bottom: 0;
  color: #385761;
  font-size: 1.08rem;
}

.player-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 34px;
  align-items: center;
  margin: 22px 0 18px;
  padding: 24px 27px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(24, 55, 59, .07);
}

.player-panel h2::before {
  content: "⌁ ";
  color: var(--teal);
}

.player-panel p, .player-panel small { color: var(--muted); font-size: .87rem; }
.player-panel p { margin-bottom: 0; }

label { display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 800; }

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

input {
  flex: 1 1 160px;
  width: 100%;
  min-width: 0;
  border: 1px solid #8eaba7;
  border-radius: 9px;
  padding: .65rem .78rem;
  background: #fff;
}

small { display: block; margin-top: 5px; }

.notice {
  margin-bottom: 20px;
  padding: 15px 18px;
  border: 1px solid #bad5cc;
  border-radius: 13px;
  background: #e7f5ef;
  color: #244d49;
  font-size: .93rem;
}

.notice button { margin-left: 12px; font-size: .86rem; }
.notice.error, .round-notice.error { border-color: #edc6b9; background: var(--coral-pale); color: var(--coral); }
.notice ul { padding-left: 20px; overflow-wrap: anywhere; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 33px 0 14px;
}

.section-heading h2 { margin: 0; color: var(--navy); font-size: 1.5rem; }
.section-heading p:not(.section-kicker) { margin: 0; color: var(--muted); font-size: .86rem; text-align: right; overflow-wrap: anywhere; }

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

.game-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 360px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 6px solid #aebfbd;
  border-radius: var(--radius);
  background: var(--paper);
  padding: 21px;
  box-shadow: 0 7px 18px rgba(27, 60, 65, .08);
  overflow-wrap: anywhere;
}

.game-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 92px;
  height: 92px;
  border-radius: 0 0 0 100%;
  background: rgba(204, 219, 216, .36);
  pointer-events: none;
}

.game-card.status-card-open { border-top-color: var(--teal); }
.game-card.status-card-completed { border-top-color: var(--lime); }
.game-card.status-card-locked { border-top-color: #81949b; background: #fbfcfb; }
.game-card.status-card-waiting { border-top-color: #b5c4c2; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.station-label {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #517078;
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 72%;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
}

.status-icon { font-size: .95rem; line-height: 1; }
.status-open { color: #075d56; background: #dcf2ea; }
.status-completed { color: #126b41; background: var(--lime-pale); }
.status-completed .status-icon { font-size: 1.1rem; font-weight: 950; }
.status-locked { color: #4f5f65; background: #e9eeee; }
.status-waiting { color: #607178; background: #edf0ef; }

.learning-goal {
  margin-bottom: 0;
  color: #445b63;
  font-size: .92rem;
}

.goal-label {
  display: block;
  margin-bottom: 3px;
  color: var(--teal-dark);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card-details {
  flex: 1;
  margin-top: 15px;
  padding: 13px 0 2px;
  border-top: 1px solid #deebe7;
  font-size: .88rem;
}

.card-details p:last-child { margin-bottom: 0; }
.score { color: #126b41; font-weight: 800; }
.ready-message { color: #315e58; }
.waiting-message { color: var(--muted); }
.conditions-label { margin-bottom: 5px; color: #405258; font-weight: 800; }
.conditions { margin: 0; padding-left: 19px; color: #53646a; }
.conditions li + li { margin-top: 6px; }

.start-button { width: 100%; margin-top: 17px; }

footer {
  margin-top: 32px;
  padding: 16px 0;
  border-top: 1px solid #c9d9d6;
  color: var(--muted);
  font-size: .84rem;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 20;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--navy);
}

.skip-link:focus { top: 12px; }

dialog {
  width: min(1180px, 96vw);
  max-width: 96vw;
  max-height: 96dvh;
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 20px 90px #0005;
}

dialog::backdrop { background: rgba(12, 42, 49, .8); }
dialog[open] { display: flex; flex-direction: column; }

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #f5faf7;
}

.game-toolbar h2 { margin: 0; overflow-wrap: anywhere; }
.game-toolbar small { margin: 0; color: var(--muted); font-size: .75rem; }
.round-notice { padding: 12px 20px; background: #eaf5f0; color: #25554d; font-size: .9rem; }
.round-notice button { margin: 6px 0 0 10px; font-size: .85rem; }
#frame-host { display: flex; min-height: 180px; flex: 1; }
iframe { display: block; width: 100%; height: 72dvh; border: 0; background: #fff; }
body:has(dialog[open]) { overflow: hidden; }

@media (max-width: 900px) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-panel { grid-template-columns: 1fr; gap: 14px; }
}

@media (max-width: 600px) {
  .page { padding: 22px 15px 28px; }
  .page-header { padding: 24px 20px 27px; border-radius: 22px; }
  .page-header::after { right: 8px; bottom: -18px; font-size: 7rem; }
  .game-grid { grid-template-columns: 1fr; }
  .player-panel { padding: 19px; }
  .input-row { flex-direction: column; }
  .input-row button { width: 100%; }
  .section-heading { display: block; }
  .section-heading p:not(.section-kicker) { margin-top: 5px; text-align: left; }
  .game-card { min-height: 0; padding: 20px; }
  .notice button { display: block; margin: 10px 0 0; }
  .game-toolbar { align-items: flex-start; padding: 12px; }
  .game-toolbar button { max-width: 140px; font-size: .8rem; }
  .game-toolbar h2 { font-size: 1rem; }
  .round-notice { padding: 10px 12px; }
  .round-notice button { display: block; margin: 8px 0 0; }
  iframe { height: 68dvh; }
}
