:root {
  --ink: #12231f;
  --paper: #f2f0e8;
  --cream: #fbfaf5;
  --line: #c8c7bd;
  --signal: #ff5b35;
  --green: #175c4d;
  --muted: #65706b;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.portal-nav, .admin-topbar {
  height: 76px;
  padding: 0 clamp(22px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 240, 232, .94);
}

.wordmark { display: inline-flex; gap: 12px; align-items: center; letter-spacing: .04em; }
.wordmark > span {
  width: 36px; height: 36px; display: grid; place-items: center;
  color: white; background: var(--green); font-weight: 800; border-radius: 4px 12px 4px 4px;
}
.admin-link, .admin-actions a, .text-button { font-weight: 700; font-size: 14px; border-bottom: 1px solid currentColor; }
.text-button { border: 0; border-bottom: 1px solid; padding: 0; background: none; color: var(--ink); }

.portal-page main { max-width: 1500px; margin: auto; }
.hero {
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr);
  gap: clamp(36px, 8vw, 120px);
  align-items: center;
  padding: clamp(64px, 8vw, 116px) clamp(22px, 6vw, 92px);
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(23, 92, 77, .09) 50%, transparent 50.2%),
    radial-gradient(circle at 10% 15%, rgba(255, 91, 53, .09), transparent 25%);
}
.eyebrow { margin: 0 0 16px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(54px, 7.3vw, 112px); line-height: .92; letter-spacing: -.065em; font-weight: 800; }
.hero h1 em { color: var(--signal); font-style: normal; }
.hero-text { max-width: 660px; margin: 34px 0; font-size: clamp(17px, 1.5vw, 21px); line-height: 1.75; color: #47534e; }
.class-strip { display: flex; gap: 18px; align-items: flex-start; font-size: 13px; font-weight: 700; }
.class-strip > span { padding-top: 7px; color: var(--muted); }
.class-list { display: flex; flex-wrap: wrap; gap: 8px; }
.class-list span { padding: 6px 10px; background: var(--cream); border: 1px solid var(--line); border-radius: 999px; }

.dispatch-board { padding: 28px; color: #f7f4e9; background: var(--ink); box-shadow: 18px 18px 0 #d7d4c7; }
.board-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.live-dot { color: #8de3b2; }
.live-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: currentColor; border-radius: 50%; box-shadow: 0 0 0 5px rgba(141, 227, 178, .12); }
.board-number { margin: 58px 0 28px; display: flex; align-items: baseline; gap: 10px; }
.board-number strong { font-size: 90px; line-height: .8; color: #ffcc4d; }
.board-number span { color: #a9b4ae; }
.track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.track i { height: 8px; background: #ffcc4d; }
.dispatch-board p { margin: 24px 0 0; color: #a9b4ae; line-height: 1.7; font-size: 14px; }

.games-section { padding: 72px clamp(22px, 6vw, 92px) 110px; background: var(--cream); border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.section-heading h2 { margin: 0; font-size: clamp(34px, 4vw, 62px); letter-spacing: -.04em; }
.section-heading > p { color: var(--muted); font-weight: 600; }
.game-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.game-card {
  position: relative; min-height: 360px; padding: 22px; overflow: hidden;
  display: flex; flex-direction: column; border: 1px solid var(--line); background: var(--paper);
  transition: transform .18s ease, box-shadow .18s ease;
}
.game-card:nth-child(1), .game-card:nth-child(2) { grid-column: span 3; }
.game-card:nth-child(n+3) { grid-column: span 2; min-height: 330px; }
.game-card.is-open:hover { transform: translateY(-5px); box-shadow: 0 16px 30px rgba(18, 35, 31, .10); }
.card-index { font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.card-symbol {
  position: absolute; right: -10px; top: 5px; font-size: 160px; line-height: 1;
  font-weight: 900; opacity: .055; transform: rotate(8deg);
}
.card-content { margin: auto 0 26px; position: relative; }
.card-status { margin-bottom: 18px; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.card-status span { display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: #9b9f9d; border-radius: 50%; }
.is-open .card-status span { background: #27a877; box-shadow: 0 0 0 5px rgba(39, 168, 119, .12); }
.game-card h3 { margin: 0 0 12px; font-size: clamp(24px, 2.2vw, 38px); letter-spacing: -.04em; }
.game-card p { max-width: 540px; margin: 0; color: #59635f; line-height: 1.65; }
.game-enter { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; border-top: 1px solid var(--line); font-weight: 800; }
.game-enter span { font-size: 24px; color: var(--signal); }
.game-enter.disabled { color: #969a98; }
.is-closed { opacity: .68; filter: grayscale(.5); }
.tone-harbor { border-top: 5px solid #177a89; }
.tone-route { border-top: 5px solid #d49117; }
.tone-lcl { border-top: 5px solid #6848b8; }
.tone-fleet { border-top: 5px solid #c94d2c; }
.tone-rail { border-top: 5px solid #2d526f; }
.tone-air { border-top: 5px solid #4477b2; }
.portal-error { grid-column: 1 / -1; padding: 36px; border: 1px dashed var(--line); text-align: center; color: var(--muted); }
footer { padding: 28px clamp(22px, 6vw, 92px); display: flex; justify-content: space-between; background: var(--ink); color: #b8c1bd; font-size: 13px; }

.admin-page { background: #e9e7de; }
.admin-actions { display: flex; gap: 24px; }
.admin-main { max-width: 1280px; margin: auto; padding: clamp(38px, 6vw, 84px) clamp(20px, 5vw, 64px) 100px; }
.login-panel { min-height: calc(100vh - 240px); display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(40px, 9vw, 130px); align-items: center; }
.login-intro h1, .dashboard-heading h1 { margin: 0; font-size: clamp(50px, 6vw, 90px); line-height: .94; letter-spacing: -.06em; }
.login-intro > p:last-child { max-width: 520px; margin-top: 30px; color: var(--muted); font-size: 18px; line-height: 1.7; }
.login-card { padding: clamp(26px, 4vw, 48px); background: var(--ink); color: white; box-shadow: 18px 18px 0 #cac7ba; }
.login-card-head { display: flex; justify-content: space-between; margin-bottom: 38px; font-weight: 800; }
.status-light { color: #8de3b2; font-size: 12px; }
.login-card label, .teacher-fields label { display: grid; gap: 9px; margin-bottom: 20px; font-size: 13px; font-weight: 700; }
.login-card input { width: 100%; padding: 14px 0; border: 0; border-bottom: 1px solid #60706a; outline: 0; color: white; background: transparent; font-size: 18px; }
.login-card input:focus { border-color: #ffcc4d; }
.form-message { min-height: 22px; color: #ff9a80; }
.primary-button {
  border: 0; padding: 15px 24px; color: white; background: var(--signal);
  font-weight: 800; box-shadow: 4px 4px 0 rgba(0, 0, 0, .18);
}
.primary-button:disabled { opacity: .55; cursor: wait; }

.dashboard-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 54px; }
.save-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
#save-indicator { width: 9px; height: 9px; background: #999; border-radius: 50%; }
#save-indicator.saved { background: #2c9c71; }
#save-indicator.dirty { background: #d18c16; }
#save-indicator.saving { background: #2c6f9c; }
#save-indicator.error { background: #c6422c; }
.setting-block { margin-bottom: 18px; padding: clamp(24px, 4vw, 46px); background: var(--cream); border: 1px solid #d0cec3; }
.setting-title { display: grid; grid-template-columns: 58px 1fr; gap: 20px; margin-bottom: 32px; }
.step-number { font-size: 12px; font-weight: 900; color: var(--signal); letter-spacing: .1em; }
.setting-title h2 { margin: 0 0 7px; font-size: 27px; }
.setting-title p { margin: 0; color: var(--muted); line-height: 1.5; }
.class-editor { display: grid; gap: 10px; margin-bottom: 16px; }
.class-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; border-bottom: 1px solid #dedcd2; }
.class-row > span { color: #999; font-size: 12px; font-weight: 800; }
.class-row input, .teacher-fields input { padding: 13px 0; border: 0; outline: 0; background: transparent; font-size: 17px; }
.class-row input:focus, .teacher-fields input:focus { box-shadow: inset 0 -2px var(--green); }
.class-row button { border: 0; padding: 8px; color: #a34d3c; background: transparent; font-size: 13px; }
.secondary-button { padding: 10px 14px; border: 1px solid var(--line); background: transparent; color: var(--green); font-weight: 800; }
.teacher-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.teacher-fields label { padding: 0 16px; border: 1px solid #d6d3c8; }
.teacher-fields label input { margin-bottom: 4px; }
.game-switches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-switch {
  display: grid; grid-template-columns: 44px 1fr auto 44px; gap: 14px; align-items: center;
  padding: 18px; border: 1px solid #d5d2c7; border-left-width: 5px; cursor: pointer;
}
.switch-mark { width: 40px; height: 40px; display: grid; place-items: center; color: white; background: var(--ink); font-weight: 900; }
.switch-copy { display: grid; gap: 4px; }
.switch-copy small { color: var(--muted); }
.game-switch input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { width: 42px; height: 24px; padding: 3px; background: #aaa; border-radius: 99px; transition: .2s; }
.toggle::after { content: ""; display: block; width: 18px; height: 18px; background: white; border-radius: 50%; transition: .2s; }
.game-switch input:checked + .toggle { background: #1e9169; }
.game-switch input:checked + .toggle::after { transform: translateX(18px); }
.switch-state { grid-column: 4; font-size: 12px; color: var(--muted); text-align: center; }
.sticky-save {
  position: sticky; bottom: 18px; display: flex; justify-content: space-between; align-items: center;
  margin-top: 28px; padding: 18px 22px; color: white; background: var(--ink); box-shadow: 0 14px 38px rgba(18, 35, 31, .25);
}
.sticky-save p { margin: 0; color: #b6c0bc; font-size: 14px; }

@media (max-width: 900px) {
  .hero, .login-panel { grid-template-columns: 1fr; }
  .hero { padding-top: 70px; }
  .dispatch-board { max-width: 520px; }
  .game-card, .game-card:nth-child(n) { grid-column: span 3; }
  .game-switches { grid-template-columns: 1fr; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .portal-nav, .admin-topbar { height: 64px; padding-inline: 16px; }
  .wordmark b { font-size: 14px; }
  .hero { min-height: auto; padding-inline: 18px; }
  .hero h1 { font-size: 52px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .games-section { padding-inline: 16px; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card, .game-card:nth-child(n) { grid-column: 1; min-height: 310px; }
  .teacher-fields { grid-template-columns: 1fr; gap: 8px; }
  .game-switch { grid-template-columns: 40px 1fr 44px; }
  .switch-state { display: none; }
  .sticky-save { align-items: stretch; flex-direction: column; gap: 14px; }
  footer { gap: 12px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
