:root {
  --tg-paper: #f4f3ee;
  --tg-panel: #ffffff;
  --tg-ink: #1c1c1b;
  --tg-muted: #666663;
  --tg-line: #d9d8d2;
  --tg-dark: #171716;
  --tg-orange: #ff7a1a;
  --tg-green: #2b9b61;
  --tg-radius: 18px;
  --tg-space-1: 4px;
  --tg-space-2: 8px;
  --tg-space-3: 12px;
  --tg-space-4: 16px;
  --tg-space-5: 20px;
  --tg-space-6: 24px;
  --tg-space-8: 32px;
  --tg-space-10: 40px;
  --tg-space-12: 48px;
  --tg-ad-rail-min: 72px;
  --tg-ad-rail-fluid: 11vw;
  --tg-ad-rail-max: 180px;
  --tg-ad-rail-height: 320px;
  --tg-game-layout-max: 1420px;
}

.arcade-sound-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--tg-space-2);
  min-height: 42px;
  margin: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--tg-line);
  color: var(--tg-muted);
  font-size: 13px;
  font-weight: 800;
}

.arcade-sound-toggle {
  min-height: 36px;
  border: 1px solid var(--tg-line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--tg-panel);
  color: var(--tg-ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.arcade-sound-toggle[aria-pressed="true"]::before { content: '♪'; margin-right: 6px; color: var(--tg-orange); }
.arcade-sound-toggle[aria-pressed="false"]::before { content: '×'; margin-right: 6px; color: var(--tg-muted); }
.arcade-sound-toggle:focus-visible { outline: 3px solid rgba(255, 122, 26, .42); outline-offset: 2px; }

* { box-sizing: border-box; }
body.teacher-game-page {
  min-height: 100vh;
  margin: 0;
  color: var(--tg-ink);
  background: var(--tg-paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
}
.teacher-shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.teacher-topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--tg-space-5);
  border-bottom: 1px solid var(--tg-line);
}
.teacher-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--tg-ink); font-weight: 900; text-decoration: none; }
.teacher-brand span:first-child { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--tg-dark); }
.teacher-scoreboard { display: flex; gap: var(--tg-space-6); }
.teacher-scoreboard span { display: grid; color: var(--tg-ink); font-size: 18px; font-variant-numeric: tabular-nums; font-weight: 900; }
.teacher-scoreboard small { color: var(--tg-muted); font-size: 10px; letter-spacing: .08em; }
.rank-button, .record-tabs button, .score-submit button, .retry-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--tg-dark);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
.rank-button:hover, .record-tabs button:hover, .score-submit button:hover, .retry-button:hover { background: #343432; }
.rank-button:focus-visible, .record-tabs button:focus-visible, .score-submit button:focus-visible, .retry-button:focus-visible, .score-submit input:focus-visible {
  outline: 3px solid rgba(255,122,26,.42);
  outline-offset: 2px;
}
.teacher-hero { padding: 58px 0 38px; }
.teacher-hero p { margin: 0; color: var(--tg-muted); line-height: 1.65; }
.teacher-hero h1 { max-width: 880px; margin: 14px 0 18px; font-size: clamp(42px, 7vw, 82px); line-height: 1.02; letter-spacing: -.035em; }
.teacher-hero h1 em { color: var(--tg-orange); font-style: normal; }
.teacher-kicker { color: var(--tg-orange); font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.teacher-game-card { overflow: hidden; border: 1px solid var(--tg-line); border-radius: var(--tg-radius); background: var(--tg-panel); }
.game-canvas-wrap { position: relative; min-height: 420px; display: grid; place-items: center; padding: 18px; background: #f7f7f5; }
.game-canvas-wrap canvas { display: block; width: 100%; max-width: 960px; height: auto; touch-action: none; }
.distance-hud { position: absolute; inset: 28px 32px auto; display: flex; justify-content: flex-end; gap: 26px; pointer-events: none; }
.distance-hud span { display: grid; min-width: 86px; text-align: right; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.distance-hud small { color: var(--tg-muted); font-size: 9px; letter-spacing: .08em; }
.control-strip { min-height: 72px; display: flex; align-items: center; gap: 24px; padding: 16px 24px; border-top: 1px solid var(--tg-line); }
.control-strip div { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.control-strip kbd { min-width: 54px; padding: 7px 10px; border: 1px solid #aaa9a3; border-radius: 6px; background: #fff; text-align: center; box-shadow: 0 2px 0 #aaa9a3; }
.control-strip p { margin-left: auto; color: var(--tg-muted); }
.game-over-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(460px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 26px;
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius);
  background: rgba(255,255,255,.97);
  text-align: center;
}
.game-over-panel[hidden] { display: none; }
.game-over-panel > strong { display: block; margin: 4px 0 8px; font-size: 46px; }
.game-over-panel p { margin: 0 0 16px; color: var(--tg-muted); }
.score-submit { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.score-submit input { min-height: 44px; border: 1px solid var(--tg-line); border-radius: 8px; padding: 0 12px; font: inherit; }
.retry-button { width: 100%; margin-top: 8px; color: var(--tg-ink); background: #e8e7e1; }
.submit-state { min-height: 22px; margin-top: 8px; color: var(--tg-muted); font-size: 13px; }
.records-section { padding: 66px 0 86px; }
.records-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.records-head h2 { margin: 6px 0 0; font-size: clamp(32px, 5vw, 54px); }
.record-tabs { display: flex; gap: 6px; }
.record-tabs button[aria-selected="true"] { background: var(--tg-orange); }
.record-list { margin: 0; padding: 0; border-top: 1px solid var(--tg-line); list-style: none; }
.record-list li { min-height: 68px; display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--tg-line); }
.record-list li > span { color: var(--tg-orange); font-weight: 900; }
.record-list li > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-list li > b { font-variant-numeric: tabular-nums; }
.record-list .empty-record { grid-template-columns: 1fr; color: var(--tg-muted); }
.tetris-frame { width: 100%; min-height: 860px; display: block; border: 0; background: #070713; }
.mission-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border-top: 1px solid var(--tg-line); background: var(--tg-line); }
.mission-strip article { min-height: 92px; padding: 18px 20px; background: #fff; }
.mission-strip article strong { display: block; margin-bottom: 5px; }
.mission-strip article span { color: var(--tg-muted); font-size: 13px; }
.mission-strip article.is-done { background: #e9f7ef; }
.teacher-game-layout {
  width: min(calc(100vw - 32px), var(--tg-game-layout-max));
  display: grid;
  grid-template-columns:
    clamp(var(--tg-ad-rail-min), var(--tg-ad-rail-fluid), var(--tg-ad-rail-max))
    minmax(0, 960px)
    clamp(var(--tg-ad-rail-min), var(--tg-ad-rail-fluid), var(--tg-ad-rail-max));
  justify-content: center;
  align-items: start;
  gap: var(--tg-space-4);
  margin-inline: 50%;
  transform: translateX(-50%);
}
.teacher-game-layout .teacher-game-card { min-width: 0; }
.teacher-game-side-ad {
  min-width: 0;
  display: grid;
  gap: var(--tg-space-2);
  color: var(--tg-muted);
}
.teacher-game-side-ad > span { font-size: 12px; font-weight: 800; }
.teacher-game-side-ad > div {
  min-height: var(--tg-ad-rail-height);
  display: grid;
  place-items: center;
  border: 1px solid var(--tg-line);
  border-radius: 8px;
  background: var(--tg-panel);
  color: var(--tg-muted);
}
.teacher-game-ad { display: grid; gap: var(--tg-space-2); margin-top: var(--tg-space-8); color: var(--tg-muted); }
.teacher-game-ad > span { font-size: 12px; font-weight: 800; }
.teacher-game-ad > div { min-height: 104px; display: grid; place-items: center; border: 1px solid var(--tg-line); border-radius: 8px; background: var(--tg-panel); color: var(--tg-muted); }
.teacher-footer { padding: 28px 0 40px; border-top: 1px solid var(--tg-line); color: var(--tg-muted); font-size: 12px; }

@media (max-width: 720px) {
  .teacher-shell { width: min(100% - 24px, 1180px); }
  .teacher-topbar { grid-template-columns: minmax(0,1fr) auto; }
  .teacher-scoreboard { grid-column: 1 / -1; grid-row: 2; padding-bottom: 14px; }
  .teacher-hero { padding-top: 38px; }
  .game-canvas-wrap { min-height: 280px; padding: 8px; }
  .distance-hud { inset: 14px 14px auto; gap: 10px; }
  .distance-hud span { min-width: 64px; font-size: 14px; }
  .control-strip { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .control-strip p { width: 100%; margin: 0; }
  .records-head { align-items: flex-start; flex-direction: column; }
  .record-tabs { width: 100%; }
  .record-tabs button { flex: 1; padding-inline: 10px; }
  .mission-strip { grid-template-columns: 1fr; }
  .tetris-frame { min-height: 960px; }
  .teacher-game-layout {
    width: auto;
    display: block;
    margin-inline: 0;
    transform: none;
  }
  .teacher-game-side-ad { display: none; }
}

@media (min-width: 721px) {
  .teacher-game-ad--fallback { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
