:root {
  color-scheme: light;
  --ink: #123c33;
  --green: #123f35;
  --green-2: #24755e;
  --mint: #dff4ec;
  --aqua: #d8f4f6;
  --lime: #bce68f;
  --paper: #fffefa;
  --canvas: #edf8f4;
  --line: #bfdcd2;
  --muted: #61776f;
  --warning: #8a5b13;
  --warning-bg: #fff4d5;
  --danger: #a43c31;
  --danger-bg: #ffe7e2;
  --shadow: 0 18px 48px rgba(18, 63, 53, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0, rgba(129, 222, 183, .38), transparent 34rem),
    linear-gradient(135deg, #e7f6f1, var(--canvas));
  font: 500 17px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, a { font: inherit; }
button { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem clamp(1rem, 4vw, 3.5rem);
  color: #fff;
  background: var(--green);
  box-shadow: 0 5px 22px rgba(8, 34, 28, .2);
}
.topbar h1, .topbar p { margin: 0; }
.topbar h1 { font-size: clamp(1.45rem, 4vw, 2.35rem); line-height: 1.1; }
.eyebrow {
  margin: 0 0 .35rem;
  color: var(--green-2);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.topbar .eyebrow { color: #b9e5d7; }
.dashboard-link { color: #fff; font-weight: 850; text-underline-offset: .2em; }

.page { width: min(1400px, calc(100% - 2rem)); margin: 0 auto; padding: 1.2rem 0 2.5rem; }
.status-strip {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 3rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: .7rem 1rem;
  background: rgba(255, 255, 255, .86);
}
.status-strip #student-identity { margin-left: auto; color: var(--muted); font-size: .88rem; }
.status-dot { width: .72rem; height: .72rem; border-radius: 50%; background: #d09b34; box-shadow: 0 0 0 4px #f8e9c4; }
body[data-connected="true"] .status-dot { background: #3b9b65; box-shadow: 0 0 0 4px #d9f0df; }
body[data-connected="error"] .status-dot { background: #c85143; box-shadow: 0 0 0 4px #f8dcd7; }

.game-shell { min-height: 62vh; }
.state-card, .panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.state-card { padding: clamp(1.4rem, 5vw, 3.5rem); }
.state-card.centered { display: grid; place-items: center; align-content: center; min-height: 55vh; text-align: center; }
.state-card h2 { margin: 0 0 .65rem; font-size: clamp(1.7rem, 4vw, 3rem); }
.state-card p:not(.eyebrow) { max-width: 660px; margin: .25rem auto; color: var(--muted); }

.assignment-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  border-radius: 18px;
  padding: 1rem 1.2rem;
  color: #fff;
  background: linear-gradient(120deg, var(--green), #1f6954);
  box-shadow: var(--shadow);
}
.assignment-head h2, .assignment-head p { margin: 0; }
.assignment-head p { color: #cde9df; }
.role-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border-radius: 999px;
  padding: .3rem .7rem;
  color: var(--green);
  background: #fff;
  font-size: .8rem;
  font-weight: 900;
}

.link-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .72fr); gap: 1rem; }
.panel { padding: clamp(1rem, 3vw, 1.6rem); }
.panel h3 { margin: 0 0 .7rem; font-size: 1.35rem; }
.own-code {
  display: inline-block;
  margin: .35rem 0 1rem;
  border: 2px dashed #82aa9d;
  border-radius: 14px;
  padding: .55rem 1rem;
  background: #eff8f4;
  font: 900 clamp(2rem, 8vw, 4rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .13em;
}
.partner-list { display: grid; gap: .55rem; margin: 1rem 0; }
.partner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: .7rem .8rem;
  background: #fff;
}
.partner span { color: var(--muted); font-size: .84rem; font-weight: 800; }
.partner.linked { border-color: #8bc79f; background: #edf9f1; }
.code-form { display: flex; gap: .65rem; margin-top: 1rem; }
.code-form input {
  width: min(12rem, 100%);
  border: 2px solid #9fc6ba;
  border-radius: 11px;
  padding: .72rem .9rem;
  color: var(--ink);
  background: #fff;
  font: 900 1.25rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.code-form input:focus { border-color: var(--green-2); outline: 3px solid rgba(36, 117, 94, .15); }

.primary, .secondary, .card-button, .slot-button, .answer-button {
  border-radius: 11px;
  font-weight: 850;
  cursor: pointer;
}
.primary { border: 0; padding: .75rem 1rem; background: var(--lime); }
.secondary { border: 2px solid #9fc6ba; padding: .65rem .9rem; background: #fff; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:not(:disabled):hover, button:not(:disabled):focus-visible { filter: brightness(.97); transform: translateY(-1px); outline: none; }

.play-layout { display: grid; grid-template-columns: minmax(270px, .72fr) minmax(580px, 1.65fr); gap: 1rem; align-items: start; }
.hand-panel { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.hand-block h3 { margin: 0 0 .55rem; font-size: 1rem; }
.hand-grid { display: grid; gap: .55rem; }
.card-button {
  width: 100%;
  border: 2px solid transparent;
  padding: .7rem;
  background: #f2f7f4;
  text-align: left;
}
.card-button.selected { border-color: var(--green-2); background: var(--mint); box-shadow: 0 0 0 3px rgba(36, 117, 94, .12); }
.card-button img { display: block; width: 100%; max-height: 150px; margin-top: .45rem; border-radius: 8px; object-fit: contain; background: #fff; }
.card-button small { display: block; margin-top: .35rem; color: var(--muted); }

.board-panel { overflow-x: auto; }
.board-head, .board-row { display: grid; grid-template-columns: .8fr 1.35fr 1fr; gap: .55rem; min-width: 720px; }
.board-head { margin-bottom: .45rem; color: var(--green-2); font-size: .75rem; font-weight: 950; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.board-row { margin-bottom: .55rem; }
.board-row.locked { border-radius: 12px; outline: 3px solid #82c897; background: #e9f8ee; }
.slot-button {
  min-height: 7.2rem;
  border: 1px solid #c9ded6;
  padding: .55rem;
  background: #fff;
  text-align: left;
}
.slot-button.owned { border-style: dashed; border-color: #6da995; }
.slot-button.target { border: 2px solid var(--green-2); background: var(--mint); }
.slot-button.empty { display: grid; place-items: center; color: #789087; text-align: center; }
.slot-button img { display: block; width: 100%; height: 6rem; object-fit: contain; }
.slot-button small { display: block; color: var(--muted); }

.feedback {
  margin-top: 1rem;
  border-radius: 12px;
  padding: .8rem 1rem;
  background: var(--aqua);
  font-weight: 750;
}
.feedback.warning { color: var(--warning); background: var(--warning-bg); }
.feedback.error { color: var(--danger); background: var(--danger-bg); }
.feedback.success { color: #1d633d; background: #e2f5e8; }
.agree-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .8rem; }
.agree-dots { display: flex; gap: .35rem; }
.agree-dot { width: .72rem; height: .72rem; border-radius: 50%; background: #cad7d2; }
.agree-dot.on { background: #3f9d66; }

.solo-card { max-width: 850px; margin: 0 auto; }
.solo-card .prompt { margin: 1rem 0; border-radius: 14px; padding: 1rem; background: #edf7f3; }
.solo-card .prompt img { display: block; max-width: min(100%, 580px); max-height: 380px; margin: 0 auto; object-fit: contain; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.answer-button { min-height: 4rem; border: 2px solid #c8dcd5; padding: .8rem 1rem; background: #fff; text-align: left; }

.credits { margin: 1.3rem auto 0; max-width: 1050px; color: var(--muted); font-size: .76rem; text-align: center; }

@media (max-width: 900px) {
  .link-layout, .play-layout { grid-template-columns: 1fr; }
  .hand-panel { position: static; }
}
@media (max-width: 620px) {
  body { font-size: 16px; }
  .topbar { align-items: flex-start; }
  .dashboard-link { font-size: .86rem; }
  .page { width: min(100% - 1rem, 1400px); }
  .status-strip { align-items: flex-start; flex-wrap: wrap; }
  .status-strip #student-identity { width: 100%; margin-left: 1.25rem; }
  .assignment-head { grid-template-columns: 1fr; }
  .role-chips { justify-content: flex-start; }
  .code-form { flex-direction: column; }
  .code-form input { width: 100%; }
  .answer-grid { grid-template-columns: 1fr; }
}
