:root {
  --shell-ink: #f7ead2;
  --shell-muted: #bca78d;
  --shell-paper: #17131a;
  --shell-paper-deep: #0c0b10;
  --shell-plum: #f0c878;
  --shell-coral: #e77759;
  --shell-gold: #d5a441;
  --shell-green: #4fae73;
  --shell-line: rgba(247, 234, 210, .17);
  --shell-shadow: 0 16px 34px rgba(0, 0, 0, .32);
  --shell-radius: 8px;
  --shell-gap: clamp(16px, 2.4vw, 28px);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--shell-paper-deep); }
body { margin: 0; color: var(--shell-ink); background: radial-gradient(circle at 50% -20%, #352238 0, var(--shell-paper-deep) 58%, #08070b 100%); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
a { color: inherit; }
.shell-home { min-height: 100vh; }
.shell { width: min(1180px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 52px) 30px; }
.shell-skip-link { position: fixed; z-index: 10; top: 8px; left: 8px; min-height: 44px; padding: 10px 14px; color: #fff; background: var(--shell-plum); transform: translateY(-160%); transition: transform .16s ease; }
.shell-skip-link:focus { transform: translateY(0); }
.shell-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--shell-line); padding-bottom: 18px; }
.shell-brand { display: flex; align-items: center; gap: 11px; letter-spacing: .08em; }
.shell-brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 3px solid var(--shell-plum); color: var(--shell-coral); font-size: 26px; transform: rotate(-4deg); }
.shell-brand strong, .shell-brand small { display: block; }
.shell-brand strong { font-size: 15px; }
.shell-brand small { margin-top: 3px; color: var(--shell-muted); font-size: 12px; letter-spacing: .12em; }
.shell-kicker { margin: 0; color: var(--shell-muted); font-size: 14px; }
.shell-hero { max-width: 720px; padding: clamp(52px, 8vw, 96px) 0 34px; }
.shell-eyebrow { margin: 0 0 12px; color: var(--shell-coral); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.shell-hero h1 { margin: 0; color: var(--shell-plum); font-size: clamp(30px, 5vw, 58px); line-height: 1.08; letter-spacing: -.04em; }
.shell-hero p:last-child { max-width: 560px; margin: 18px 0 0; color: var(--shell-muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.7; }
.shell-game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--shell-gap); }
.shell-loading { grid-column: 1 / -1; margin: 0; padding: 36px; border: 2px dashed var(--shell-line); border-radius: var(--shell-radius); color: var(--shell-muted); text-align: center; }
.shell-game-card { position: relative; display: flex; min-width: 0; flex-direction: column; padding: 24px; border: 2px solid var(--shell-line); border-top: 7px solid var(--game-accent, var(--shell-coral)); border-radius: var(--shell-radius); color: var(--shell-ink); background: linear-gradient(160deg, rgba(39, 29, 42, .98), rgba(22, 18, 25, .98)); box-shadow: var(--shell-shadow); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.shell-game-card:hover { transform: translateY(-5px); border-color: var(--game-accent, var(--shell-coral)); box-shadow: 0 20px 38px rgba(0, 0, 0, .42); }
.shell-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shell-game-icon { font-size: 46px; line-height: 1; }
.shell-game-code { color: var(--game-accent, var(--shell-coral)); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.shell-game-card h2 { margin: 20px 0 8px; color: var(--shell-plum); font-size: 25px; line-height: 1.25; }
.shell-card-description { min-height: 82px; margin: 0; color: var(--shell-muted); font-size: 15px; line-height: 1.75; }
.shell-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.shell-tags span { padding: 5px 8px; border: 1px solid color-mix(in srgb, var(--game-accent, var(--shell-coral)) 44%, transparent); border-radius: 4px; color: var(--game-accent, var(--shell-coral)); background: color-mix(in srgb, var(--game-accent, var(--shell-coral)) 13%, transparent); font-size: 12px; font-weight: 800; }
.shell-progress { margin-top: 24px; }
.shell-progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: rgba(77,49,88,.12); }
.shell-progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--game-accent, var(--shell-coral)); transition: width .35s ease; }
.shell-progress-label { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--shell-muted); font-size: 13px; }
.shell-progress-resume { margin-top: 0; min-height: 28px; align-items: center; }
.shell-card-cta { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-top: 22px; padding: 9px 14px; border-radius: 4px; color: #1a1117; background: var(--game-accent, var(--shell-coral)); font-size: 14px; font-weight: 900; }
.shell-card-cta span { font-size: 20px; }
.shell-footer { display: flex; justify-content: center; gap: 10px; margin-top: 34px; color: var(--shell-muted); font-size: 13px; }
.shell-error { grid-column: 1 / -1; display: grid; gap: 12px; padding: 26px; border: 2px solid var(--shell-coral); border-radius: var(--shell-radius); background: rgba(44, 27, 35, .94); color: var(--shell-muted); }
.shell-error strong { color: var(--shell-ink); font-size: 20px; }
.shell-error div { display: flex; flex-wrap: wrap; gap: 10px; }
.shell-error a, .shell-error button { min-height: 44px; padding: 10px 14px; border: 1px solid var(--shell-coral); border-radius: 4px; color: var(--shell-ink); background: transparent; font: inherit; text-decoration: none; cursor: pointer; }
.shell-error a:hover, .shell-error button:hover { background: rgba(231,119,89,.16); }
:focus-visible { outline: 4px solid #4c8dca; outline-offset: 4px; }
@media (max-width: 900px) { .shell-game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .shell-kicker { max-width: 240px; text-align: right; } }
@media (max-width: 768px) { .shell { padding-top: 18px; } .shell-hero { padding-top: 58px; } .shell-game-grid { grid-template-columns: 1fr; } .shell-card-description { min-height: 0; } }
@media (max-width: 390px) { .shell { padding-right: 14px; padding-left: 14px; } .shell-header { align-items: flex-start; flex-direction: column; } .shell-kicker { max-width: none; text-align: left; } .shell-hero { padding-top: 44px; } .shell-game-card { padding: 20px; } .shell-footer { flex-wrap: wrap; line-height: 1.6; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* Local learner profile: flat context band, shared by the hallway and play shell. */
.shell-profile { display: grid; grid-template-columns: minmax(220px, .85fr) minmax(300px, 1fr) minmax(220px, .8fr); align-items: center; gap: var(--shell-space-5); margin: 0 0 28px; padding: 18px 20px; border-top: 3px solid var(--shell-plum); border-bottom: 1px solid var(--shell-line); background: rgba(32, 24, 37, .82); }
.profile-band-copy p, .profile-band-copy h2, .profile-band-copy .profile-eyebrow { margin: 0; }
.profile-band-copy .profile-eyebrow { color: var(--shell-coral); font-size: 11px; font-weight: 900; letter-spacing: .16em; }
.profile-band-copy h2 { margin-top: 6px; color: var(--shell-plum); font-size: 22px; }
.profile-band-copy p:last-child { margin-top: 7px; color: var(--shell-muted); font-size: 13px; line-height: 1.55; }
.profile-band-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.profile-current { display: flex; align-items: center; gap: 10px; min-width: 0; }
.profile-current b, .profile-current small { display: block; }
.profile-current b { color: var(--shell-ink); font-size: 15px; }
.profile-current small { margin-top: 4px; color: var(--shell-muted); font-size: 12px; }
.profile-avatar { display: inline-grid; flex: none; place-items: center; width: 34px; height: 34px; border: 2px solid var(--shell-plum); border-radius: 50%; color: #1a1117; background: var(--shell-plum); font-weight: 900; }
.profile-empty-copy { margin: 0; color: var(--shell-muted); font-size: 13px; line-height: 1.6; }
.profile-create-form { display: flex; flex: 1; flex-wrap: wrap; align-items: end; gap: 8px; min-width: 0; }
.profile-create-form[hidden] { display: none; }
.profile-create-form label { width: 100%; color: var(--shell-muted); font-size: 12px; }
.profile-create-form input { flex: 1 1 120px; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--shell-line); border-radius: var(--shell-radius-sm); color: var(--shell-ink); background: rgba(12, 11, 16, .72); font: inherit; }
.profile-create-form button, .profile-secondary { min-height: 44px; padding: 0 14px; border: 1px solid var(--shell-plum); border-radius: var(--shell-radius-sm); color: #1a1117; background: var(--shell-plum); font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; cursor: pointer; }
.profile-secondary { color: var(--shell-ink); background: transparent; }
.profile-list-wrap { min-width: 0; }
.profile-list-wrap h3 { margin: 0 0 7px; color: var(--shell-muted); font-size: 12px; font-weight: 800; }
.profile-list, .profile-legacy ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.profile-list button { min-height: 44px; padding: 0 11px; border: 1px solid var(--shell-line); border-radius: var(--shell-radius-sm); color: var(--shell-ink); background: transparent; font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; cursor: pointer; }
.profile-list button[aria-selected="true"], .profile-list button:hover { border-color: var(--shell-plum); background: rgba(240, 200, 120, .14); }
.profile-inline-status { min-height: 20px; margin-top: 8px; color: var(--shell-muted); font-size: 12px; }
.profile-error { display: grid; gap: 7px; color: var(--shell-muted); }
.profile-error strong, .profile-gate-warning { color: var(--shell-danger); }
.profile-legacy { grid-column: 1 / -1; padding-top: 14px; border-top: 1px solid var(--shell-line); }
.profile-legacy h3 { margin: 0; color: var(--shell-plum); font-size: 14px; }
.profile-legacy p, .profile-legacy li > span { color: var(--shell-muted); font-size: 12px; line-height: 1.5; }
.profile-legacy p { margin: 5px 0 10px; }
.profile-legacy li { display: grid; gap: 5px; min-width: 190px; padding: 8px 10px; border-left: 2px solid var(--shell-coral); background: rgba(231, 119, 89, .07); }
.profile-legacy li strong { color: var(--shell-ink); font-size: 12px; }
.profile-legacy li button { min-height: 44px; margin-right: 5px; padding: 0 9px; border: 1px solid var(--shell-coral); border-radius: var(--shell-radius-sm); color: var(--shell-ink); background: transparent; font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; cursor: pointer; }

/* Profile context stays over the compact 44px game bar. */
.shell-play { position: relative; }
.play-profile-row { position: absolute; z-index: 4; top: 0; right: 76px; display: flex; align-items: center; height: var(--shell-topbar-h); pointer-events: none; }
.play-profile { position: relative; pointer-events: auto; }
.play-profile-button { display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; max-width: 210px; padding: 0 10px; overflow: hidden; border: 1px solid var(--shell-line); border-radius: var(--shell-radius-sm); color: var(--shell-ink); background: rgba(32, 40, 55, .7); font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.play-profile-button > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.play-profile-menu { position: absolute; z-index: 20; top: 50px; right: 0; width: 240px; padding: 8px; border: 1px solid var(--shell-line); color: var(--shell-ink); background: #171c26; box-shadow: var(--shell-shadow); }
.play-profile-menu[hidden] { display: none; }
.play-profile-menu ul { display: grid; gap: 4px; margin: 0 0 7px; padding: 0; list-style: none; }
.play-profile-menu button { display: block; width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid transparent; color: var(--shell-ink); background: transparent; font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; text-align: left; cursor: pointer; }
.play-profile-menu button:hover, .play-profile-menu button[aria-checked="true"] { border-color: var(--shell-plum); background: rgba(240, 200, 120, .14); }
.play-profile-menu > button { border-top: 1px solid var(--shell-line); color: var(--shell-plum); }
.play-profile-gate { z-index: 3; }
.play-profile-gate #playProfileGateContent { display: grid; gap: 12px; width: min(560px, 100%); }
.play-profile-gate .profile-gate-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.play-profile-gate .profile-gate-actions button { min-height: 44px; padding: 0 14px; border: 1px solid var(--shell-plum); border-radius: var(--shell-radius-sm); color: #1a1117; background: var(--shell-plum); font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; cursor: pointer; }
.play-profile-gate .profile-gate-actions .profile-secondary { color: var(--shell-ink); background: transparent; }
.play-profile-gate .profile-gate-copy { display: grid; gap: 5px; }
.play-profile-gate .profile-gate-copy strong { color: var(--shell-ink); font-size: 19px; }
.play-profile-gate .profile-gate-copy span, .play-profile-gate .profile-gate-form { color: var(--shell-muted); line-height: 1.6; }
.play-profile-gate .profile-gate-form { width: min(560px, 100%); padding: 14px; border: 1px solid var(--shell-line); text-align: left; }
.play-profile-gate .shell-profile { display: block; margin: 0; padding: 0; border: 0; background: transparent; }
.play-profile-gate .profile-band-copy { display: none; }
.play-profile-gate .profile-list-wrap { margin-top: 12px; }
.play-profile-gate .profile-legacy { display: none; }
.play-profile-gate > a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--shell-line); color: var(--shell-ink); text-decoration: none; }

.shell-play .play-topbar { padding-right: 130px; }

/* Product Shell: shared game frame */
:root {
  --shell-topbar-h: 44px;
  --shell-control-min: 44px;
  --shell-space-1: 4px;
  --shell-space-2: 8px;
  --shell-space-3: 12px;
  --shell-space-4: 16px;
  --shell-space-5: 24px;
  --shell-space-6: 32px;
  --shell-radius-sm: 6px;
  --shell-radius-md: 10px;
  --shell-radius-lg: 14px;
  --shell-bg: #10131a;
  --shell-surface: #171c26;
  --shell-surface-2: #202837;
  --shell-ink: #f6f1e8;
  --shell-muted: #b7b3ab;
  --shell-line: rgba(246, 241, 232, .16);
  --shell-focus: #8cc8ff;
  --shell-success: #6fcb91;
  --shell-warning: #f1bf5a;
  --shell-danger: #ef8275;
}

.shell-play [data-game-theme="blocks-isle"] {
  --game-accent: #e77759;
  --game-accent-strong: #f39a73;
  --game-surface: #15202a;
  --game-line: #315267;
  --brand: var(--game-accent);
  --brand-deep: #c35843;
}

.shell-play [data-game-theme="algo-lab"] {
  --game-accent: #d5a441;
  --game-accent-strong: #f2c765;
  --game-surface: #111a28;
  --game-line: #334157;
  --brand: var(--game-accent);
  --brand-deep: #a77c27;
}

.shell-play [data-game-theme="code-maze"] {
  --game-accent: #4fae73;
  --game-accent-strong: #93c5fd;
  --game-surface: #0f172a;
  --game-line: #294564;
  --game-warning: #fbbf24;
}

.shell-play {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% -20%, #352238 0, var(--shell-paper-deep) 58%, #08070b 100%);
}

.shell-play .play-topbar {
  display: none;
  align-items: center;
  gap: var(--shell-space-3);
  flex: none;
  height: var(--shell-topbar-h);
  min-height: var(--shell-topbar-h);
  box-sizing: border-box;
  padding: 8px clamp(12px, 2.4vw, 26px);
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 2px solid var(--shell-line);
  background: rgba(12, 11, 16, .92);
}

.shell-play .play-profile-row { display: none; }

.shell-play .play-back,
.shell-play .play-fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--shell-control-min);
  min-height: var(--shell-control-min);
  border: 2px solid var(--shell-line);
  border-radius: var(--shell-radius-sm);
  color: var(--shell-ink);
  background: transparent;
  font: 700 14px -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.shell-play .play-back { gap: 8px; padding: 0 14px; }
.shell-play .play-back:hover { border-color: var(--game-accent, var(--shell-coral)); }
.shell-play .play-identity { display: none; }
.shell-play .play-title,
.shell-play .play-badge,
.shell-play .play-progress { display: none; }
.shell-play .play-icon { font-size: 28px; line-height: 1; }
.shell-play .play-title { color: var(--game-accent, var(--shell-plum)); font-size: 18px; font-weight: 900; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-play .play-badge { flex: none; padding: 3px 9px; border-radius: 999px; color: #1a1117; background: var(--game-accent, var(--shell-green)); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.shell-play .play-progress { min-width: 0; margin-left: auto; overflow: hidden; color: var(--shell-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.shell-play .play-fullscreen { flex: none; font-size: 18px; line-height: 1; }
.shell-play .play-fullscreen:hover { border-color: var(--shell-plum); }
.shell-play .play-stage { position: relative; flex: 1; min-height: 0; background: var(--shell-paper-deep); }
.shell-play .play-frame { display: block; width: 100%; height: 100%; border: 0; }
.shell-play .play-message { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; padding: 24px; color: var(--shell-muted); text-align: center; background: var(--shell-paper-deep); }
.shell-play .play-message[hidden] { display: none; }
.shell-play .play-message strong { color: var(--shell-ink); font-size: 20px; }
.shell-play .play-message span { max-width: 480px; line-height: 1.7; }
.shell-play .play-message div { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.shell-play .play-message button,
.shell-play .play-message a { display: inline-flex; align-items: center; min-height: var(--shell-control-min); padding: 0 16px; border: 1px solid var(--shell-coral); border-radius: var(--shell-radius-sm); color: var(--shell-ink); background: transparent; font: 700 14px -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.shell-play .play-message button:hover,
.shell-play .play-message a:hover { background: rgba(231, 119, 89, .16); }
.shell-play .play-message a[data-direct] { border-color: var(--game-accent, var(--shell-plum)); }
.shell-play .play-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 900px) {
  .shell-profile { grid-template-columns: minmax(220px, 1fr) minmax(240px, 1fr); }
  .shell-play .play-topbar { gap: 10px; }
  .shell-play .play-topbar { padding-right: 112px; }
  .play-profile-button { max-width: 170px; }
}

@media (max-width: 768px) {
  .shell-play .play-topbar { padding-right: 10px; }
  .play-profile-row { position: absolute; top: 0; right: 54px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; pointer-events: none; }
  .play-profile { width: auto; }
  .play-profile-button { width: 44px; max-width: 44px; justify-content: center; padding: 0; }
  .play-profile-button > span:last-child { display: none; }
  .shell-play .play-profile-menu { position: fixed; top: 50px; right: 10px; left: 10px; width: auto; }
}

@media (max-width: 390px) {
  .shell-profile { display: block; padding: 16px; }
  .profile-band-main { display: block; margin-top: 14px; }
  .profile-create-form { margin-top: 12px; }
  .profile-list-wrap { margin-top: 14px; }
  .profile-legacy { margin-top: 14px; }
  :root { --shell-topbar-h: 44px; }
  .shell-play .play-topbar { gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); }
  .shell-play .play-topbar { padding-right: 10px; }
  .play-profile-row { position: absolute; top: 0; right: 54px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; pointer-events: none; }
  .play-profile { width: auto; }
  .play-profile-button { width: 44px; max-width: 44px; justify-content: center; padding: 0; }
  .play-profile-button > span:last-child { display: none; }
  .play-profile-menu { top: 46px; right: 0; left: 0; width: min(100vw - 20px, 360px); }
  .shell-play .play-back { padding: 0 8px; font-size: 0; }
  .shell-play .play-back::after { content: "← 返回"; font-size: 12px; }
  .shell-play .play-icon,.shell-play .play-title,.shell-play .play-badge { display: none; }
  .shell-play .play-progress { display: block; max-width: 24vw; font-size: 11px; }
  .shell-play .play-badge { padding: 3px 6px; font-size: 10px; }
}
@media (max-width: 390px) {
  .shell-play .play-profile-menu { position: fixed; top: 50px; right: 10px; left: 10px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-shell="1"] body *,
  html[data-shell="1"] body *::before,
  html[data-shell="1"] body *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  html[data-shell="1"] body::after { display: none; }
}
