:root {
  color-scheme: dark;
  --ink: #111314;
  --ink-2: #191c1d;
  --panel: rgba(29, 33, 34, .92);
  --line: rgba(232, 236, 228, .18);
  --text: #f3f4ee;
  --muted: #aeb8b2;
  --teal: #54b6a7;
  --amber: #f2b84b;
  --coral: #e76f51;
  --sage: #94b49f;
  --paper: #e8e2d5;
  --danger: #d95d52;
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--text); }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button, select, input, textarea { border-radius: 8px; }
button {
  border: 1px solid rgba(255,255,255,.12);
  background: #f0eee5;
  color: #141716;
  padding: 10px 14px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 700;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.quiet { background: rgba(255,255,255,.08); color: var(--text); }
button.danger { background: var(--danger); color: white; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.24);
  color: var(--text);
  padding: 11px 12px;
}
textarea { resize: vertical; line-height: 1.5; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
a { color: var(--text); text-decoration: none; }

.portrait-guard {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #111314;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px;
}
.portrait-guard strong { font-size: 28px; }
.portrait-guard span { color: var(--muted); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(180deg, rgba(244,238,222,.06), transparent 42%),
    radial-gradient(circle at 18% 0%, rgba(84,182,167,.20), transparent 26%),
    linear-gradient(110deg, #111314, #1a1d1d 45%, #171413);
}

.topbar {
  position: relative;
  height: 72px;
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 2px; color: var(--sage); font-size: 12px; font-weight: 800; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
.brand-logo {
  display: grid;
  gap: 1px;
  line-height: 1.05;
}
.brand-logo strong {
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 950;
  letter-spacing: .02em;
}
.brand-logo span {
  color: var(--sage);
  font-size: 12px;
  font-weight: 800;
}
.mode-tabs { display: flex; gap: 8px; }
.tab { background: rgba(255,255,255,.08); color: var(--text); min-width: 92px; }
.tab.is-active { background: var(--teal); color: #071110; }

.view { display: none; min-height: calc(100vh - 72px); }
.view.is-active { display: block; }

.arena-grid {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(360px, 420px);
}
.exam-stage {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 36%),
    linear-gradient(180deg, #242323 0 58%, #3c3129 58% 100%);
  border-right: 1px solid var(--line);
}
.judge-row {
  height: 45%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5vw;
  padding: 34px 5vw 0;
  perspective: 900px;
}
.judge {
  width: clamp(120px, 16vw, 188px);
  height: 240px;
  position: relative;
  transform-origin: 50% 100%;
  animation: judgeIdle 5s ease-in-out infinite;
}
.judge-center { transform: scale(1.1); animation-duration: 4.6s; }
.judge-right { animation-delay: .7s; }
.judge-left { animation-delay: 1.2s; }
.judge-head {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 72px;
  height: 82px;
  transform: translateX(-50%);
  border-radius: 40% 40% 44% 44%;
  background: #d7b095;
  box-shadow: inset 0 -9px rgba(102,68,54,.18);
}
.judge-head::before {
  content: "";
  position: absolute;
  inset: -9px 6px auto;
  height: 28px;
  border-radius: 24px 24px 8px 8px;
  background: #2b2520;
}
.judge-head::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 39px;
  height: 3px;
  border-radius: 2px;
  background: #4c3328;
  box-shadow: 0 16px 0 -1px rgba(76,51,40,.65);
  animation: blink 4.8s infinite;
}
.judge-head i {
  position: absolute;
  left: 16px;
  top: 35px;
  width: 40px;
  height: 12px;
  border-top: 2px solid rgba(35,31,28,.65);
  border-left: 2px solid rgba(35,31,28,.65);
  border-right: 2px solid rgba(35,31,28,.65);
  border-radius: 10px 10px 2px 2px;
}
.judge-body {
  position: absolute;
  left: 50%;
  top: 78px;
  width: 124px;
  height: 118px;
  transform: translateX(-50%);
  border-radius: 36px 36px 10px 10px;
  background: linear-gradient(90deg, #2d3536, #40494a);
}
.judge-body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 34px;
  height: 74px;
  transform: translateX(-50%);
  background: #ede4d0;
  clip-path: polygon(10% 0, 90% 0, 62% 100%, 38% 100%);
}
.judge-body b {
  position: absolute;
  right: -18px;
  bottom: 16px;
  width: 54px;
  height: 12px;
  background: #d7b095;
  border-radius: 999px;
  transform-origin: left center;
  animation: writeNote 2.6s ease-in-out infinite;
}
.judge-desk {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 172px;
  height: 48px;
  transform: translateX(-50%);
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #67503e, #3e2c22);
  box-shadow: 0 16px 30px rgba(0,0,0,.28);
}
.judge-desk em {
  position: absolute;
  right: 22px;
  top: -8px;
  width: 44px;
  height: 28px;
  background: var(--paper);
  border-radius: 4px;
  transform: rotate(-5deg);
}
.stage-floor {
  position: absolute;
  inset: 45% 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7vw;
  padding: 18px 5vw 28px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.05), transparent 22% 78%, rgba(255,255,255,.04)),
    linear-gradient(180deg, #554234, #2c241f);
}
.lottery-wrap {
  position: relative;
  width: min(48vw, 540px);
  aspect-ratio: 13 / 8;
  display: grid;
  place-items: center;
}
#lotteryCanvas { width: 100%; height: 100%; }
.hand-button {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  background: var(--amber);
  min-width: 190px;
}
.candidate-mark {
  width: 18vw;
  min-width: 160px;
  height: 44%;
  align-self: end;
  border-radius: 110px 110px 12px 12px;
  background: linear-gradient(180deg, #69716c, #242828);
  display: grid;
  place-items: start center;
  padding-top: 24px;
  color: rgba(255,255,255,.72);
  box-shadow: 0 22px 40px rgba(0,0,0,.25);
}

.exam-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  background: rgba(8,10,10,.34);
}
.panel-block, .editor-band, .manage-band, .settings-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.license-status-box {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid rgba(84, 182, 167, .28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(84, 182, 167, .16), rgba(255, 255, 255, .04)),
    rgba(0, 0, 0, .12);
}
.license-status-box span {
  color: var(--sage);
  font-size: 12px;
  font-weight: 850;
}
.license-status-box strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}
.small-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}
.small-link-row a {
  color: var(--paper);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(232, 226, 213, .45);
}
.admin-icon-link {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(232, 236, 228, .18);
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  color: rgba(243, 244, 238, .74);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}
.admin-icon-link:hover {
  border-color: rgba(84, 182, 167, .45);
  color: var(--paper);
}
.small-link-row a::before {
  content: "· ";
  color: var(--amber);
}
.license-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}
.license-strip strong { color: var(--text); }
.row-between, .section-head, .button-row, .timer-actions, .question-actions, .stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-between, .section-head, .stat-row { justify-content: space-between; }
.stat-row {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.stat-row b { color: var(--amber); font-size: 18px; }
.question-block h2 {
  min-height: 92px;
  display: flex;
  align-items: center;
  font-size: clamp(20px, 2.3vw, 32px);
  line-height: 1.28;
}
.judge-speech {
  margin: 0 0 8px;
  color: var(--amber);
  font-weight: 800;
}
.answer-text {
  margin: 0 0 12px;
  padding: 12px;
  min-height: 96px;
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  color: #eae5d9;
  line-height: 1.55;
  font-size: 13px;
}
.is-hidden { display: none !important; }
.timer-display {
  text-align: center;
  font-size: clamp(44px, 7vw, 82px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--paper);
  padding: 10px 0 14px;
}
.timer-actions, .question-actions, .button-row { flex-wrap: wrap; }
.timer-actions button, .question-actions button, .rating-block button { flex: 1 1 auto; }
.stop-call {
  margin: 12px 0 0;
  padding: 12px;
  text-align: center;
  border-radius: 8px;
  background: var(--coral);
  color: white;
  font-weight: 900;
  font-size: 22px;
  animation: callPulse .9s ease-in-out infinite;
}
.rating-block {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.rating-block button:nth-child(1) { background: #3b3f40; color: white; }
.rating-block button:nth-child(2) { background: var(--coral); color: white; }
.rating-block button:nth-child(3) { background: var(--teal); color: #06110f; }
.rating-block button:nth-child(4) { background: var(--sage); color: #111314; }

.cards-grid {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}
.input-layout { display: grid; gap: 12px; }
.file-button {
  width: auto;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  cursor: pointer;
  font-weight: 800;
}
.file-button input { display: none; }
.manage-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(280px, .95fr) minmax(360px, 1.05fr);
  gap: 12px;
  min-height: 370px;
}
.card-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 52vh;
  background: rgba(0,0,0,.18);
}
.card-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px;
}
.card-row.is-active { background: rgba(84,182,167,.18); }
.card-row small { color: var(--muted); }
.card-form { display: grid; gap: 12px; }
.settings-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 14px;
}
.notice {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}
.link-grid {
  display: grid;
  gap: 6px;
}
.link-grid a {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.official-link-list a::before {
  content: "· ";
  color: var(--amber);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #f0eee5;
  color: #111314;
  box-shadow: 0 18px 46px rgba(0,0,0,.34);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }

@keyframes judgeIdle {
  0%, 100% { transform: translateY(0) rotateX(0); }
  45% { transform: translateY(3px) rotateX(2deg); }
}
@keyframes blink {
  0%, 46%, 50%, 100% { transform: scaleY(1); }
  48% { transform: scaleY(.12); }
}
@keyframes writeNote {
  0%, 100% { transform: rotate(-8deg) translateX(0); }
  50% { transform: rotate(6deg) translateX(8px); }
}
@keyframes callPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@media (max-width: 980px) {
  .topbar { height: 64px; padding: 10px 12px; }
  h1 { font-size: 18px; }
  .tab { min-width: 70px; padding: 8px 10px; }
  .arena-grid { grid-template-columns: 1fr 340px; min-height: calc(100vh - 64px); }
  .exam-panel { padding: 10px; gap: 8px; }
  .panel-block { padding: 10px; }
  .question-block h2 { min-height: 70px; font-size: 20px; }
  .rating-block { grid-template-columns: repeat(2, 1fr); }
  .stage-floor { gap: 3vw; padding-inline: 3vw; }
}

@media (orientation: portrait) and (max-width: 760px) {
  .portrait-guard { display: grid; }
}

/* Full-screen simulator overlay */
:root { --topbar-height: 72px; }
html, body { width: 100%; height: 100%; overflow: hidden; }
.app-shell {
  height: 100dvh;
  min-height: 100dvh;
  display: block;
  overflow: hidden;
}
.topbar {
  position: fixed;
  z-index: 30;
  top: max(0px, env(safe-area-inset-top));
  left: max(0px, env(safe-area-inset-left));
  right: max(0px, env(safe-area-inset-right));
  background: rgba(17, 19, 20, .62);
  backdrop-filter: blur(14px);
}
.view {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}
#view-cards,
#view-settings {
  overflow: auto;
  padding-top: var(--topbar-height);
}
.arena-grid {
  position: relative;
  height: 100dvh;
  min-height: 100dvh;
  display: block;
}
.exam-stage {
  position: absolute;
  inset: 0;
  border-right: 0;
}
.judge-row {
  height: 50dvh;
  padding-top: calc(var(--topbar-height) + 20px);
  gap: clamp(34px, 8vw, 116px);
}
.judge {
  width: clamp(106px, 13vw, 176px);
  height: clamp(188px, 27vh, 240px);
}
.stage-floor {
  inset: 48dvh 0 0;
  justify-content: flex-start;
  padding-left: clamp(18px, 8vw, 116px);
  padding-right: min(430px, 39vw);
}
.lottery-wrap {
  width: min(45vw, 560px);
  min-width: 300px;
}
.candidate-mark {
  position: absolute;
  right: min(430px, 39vw);
  bottom: 0;
  width: clamp(120px, 15vw, 220px);
  min-width: 0;
  height: 42%;
  opacity: .82;
}
.exam-panel {
  position: absolute;
  z-index: 20;
  top: calc(var(--topbar-height) + 10px);
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(392px, 37vw);
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(232, 236, 228, .18);
  border-radius: 8px;
  background: rgba(13, 16, 16, .58);
  backdrop-filter: blur(16px);
}
.panel-block {
  background: rgba(18, 22, 22, .64);
  box-shadow: 0 14px 34px rgba(0,0,0,.18);
}
.question-block h2 {
  min-height: 76px;
  font-size: clamp(18px, 2.1vw, 30px);
}
.timer-display {
  font-size: clamp(40px, 5.6vw, 78px);
}
.hand-button.is-drawing {
  animation: drawButtonKick .85s ease-in-out;
}
.admin-tools.is-hidden {
  display: none !important;
}

@keyframes drawButtonKick {
  0%, 100% { transform: translateX(-50%) scale(1); }
  35% { transform: translateX(-50%) scale(1.08) rotate(-1deg); }
  70% { transform: translateX(-50%) scale(.98) rotate(1deg); }
}

@media (max-width: 980px) {
  :root { --topbar-height: 64px; }
  .exam-panel {
    top: calc(var(--topbar-height) + 8px);
    right: 8px;
    bottom: 8px;
    width: min(350px, 43vw);
  }
  .stage-floor {
    padding-left: 5vw;
    padding-right: 45vw;
  }
  .lottery-wrap {
    width: min(47vw, 430px);
    min-width: 250px;
  }
  .candidate-mark {
    right: 45vw;
  }
  .judge-row {
    gap: clamp(18px, 6vw, 64px);
  }
  .judge {
    transform: scale(.86);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --topbar-height: 56px; }
  .topbar {
    height: var(--topbar-height);
    padding: 7px 10px;
  }
  .topbar h1 { font-size: 16px; }
  .topbar .eyebrow { display: none; }
  .tab {
    min-width: 62px;
    min-height: 36px;
    padding: 7px 9px;
  }
  .judge-row {
    height: 48dvh;
    padding-top: calc(var(--topbar-height) + 4px);
  }
  .judge {
    transform: scale(.72);
  }
  .stage-floor {
    inset: 45dvh 0 0;
    padding-left: 3vw;
    padding-right: 44vw;
  }
  .lottery-wrap {
    width: 42vw;
    min-width: 220px;
  }
  .candidate-mark {
    height: 36%;
  }
  .exam-panel {
    top: calc(var(--topbar-height) + 6px);
    bottom: 6px;
    right: 6px;
    width: 41vw;
    padding: 7px;
    gap: 7px;
  }
  .panel-block { padding: 8px; }
  .license-strip { font-size: 12px; }
  .question-block h2 {
    min-height: 46px;
    font-size: 16px;
  }
  .judge-speech,
  .stat-row,
  label,
  .notice { font-size: 11px; }
  .timer-display {
    font-size: 42px;
    padding: 2px 0 8px;
  }
  button {
    min-height: 34px;
    padding: 7px 8px;
  }
  .rating-block {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }
}

/* v48: public content pages */
body.content-page {
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(circle at 20% 0%, rgba(84, 182, 167, .16), transparent 32%), linear-gradient(135deg, #111514, #1a201f 62%, #141210);
  color: var(--text);
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.content-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.content-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.content-nav a,
.content-article a {
  color: var(--paper);
  text-underline-offset: 4px;
}

.content-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  text-decoration: none;
  font-weight: 800;
}

.content-article {
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  background: rgba(22, 26, 25, .88);
  box-shadow: 0 24px 80px rgba(0,0,0,.34);
}

.content-article h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 7vw, 56px);
  line-height: 1.08;
}

.content-article h2 {
  margin: 30px 0 10px;
  font-size: clamp(21px, 4vw, 30px);
}

.content-article p,
.content-article li {
  color: rgba(243, 244, 238, .82);
  font-size: 17px;
  line-height: 1.75;
}

.content-article code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,.10);
  color: var(--paper);
}


/* Immersive entry and deeper 3D polish */
.start-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 18%, rgba(242, 184, 75, .20), transparent 24%),
    linear-gradient(180deg, rgba(17, 19, 20, .88), rgba(17, 19, 20, .96));
  backdrop-filter: blur(18px);
}
.start-gate.is-hidden { display: none; }
.start-card {
  width: min(520px, 92vw);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 24px;
  background: rgba(20, 24, 24, .78);
  box-shadow: 0 30px 90px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.08);
}
.start-card h2 { font-size: clamp(26px, 5vw, 42px); }
.start-card p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.fullscreen-nav {
  min-width: 76px;
  background: rgba(255,255,255,.06);
  color: var(--text);
}
.exam-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 24% 58%, rgba(255,255,255,.10), transparent 25%),
    radial-gradient(ellipse at 55% 20%, rgba(242,184,75,.11), transparent 30%),
    linear-gradient(180deg, rgba(0,0,0,.0), rgba(0,0,0,.32));
  z-index: 0;
}
.judge-row,
.stage-floor {
  z-index: 1;
}
.judge {
  filter: drop-shadow(0 22px 24px rgba(0,0,0,.36));
}
.judge-body {
  box-shadow: inset 16px 0 22px rgba(255,255,255,.05), inset -18px 0 22px rgba(0,0,0,.20);
}
.judge-desk {
  box-shadow: 0 26px 36px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.18);
}
.stage-floor::before {
  content: "";
  position: absolute;
  left: 4vw;
  right: 4vw;
  top: 6%;
  height: 22%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent);
  transform: perspective(620px) rotateX(64deg);
  transform-origin: 50% 0;
}
.lottery-wrap {
  filter: drop-shadow(0 28px 38px rgba(0,0,0,.38));
}
#lotteryCanvas {
  filter: saturate(1.05) contrast(1.05);
}
.candidate-mark {
  display: none !important;
}
.stage-floor {
  padding-right: min(400px, 36vw);
}
.lottery-wrap {
  width: min(52vw, 620px);
}

@media (orientation: landscape) and (max-height: 520px) {
  .start-card {
    padding: 16px;
  }
  .fullscreen-nav {
    display: none;
  }
  .stage-floor {
    padding-right: 42vw;
  }
  .lottery-wrap {
    width: min(45vw, 410px);
  }
}


/* Product polish: judge character and text import */
.judge-head {
  background: linear-gradient(180deg, #e2b99d, #c99072);
}
.judge-head::after {
  top: 35px;
  height: 3px;
  background: #3c2c26;
  box-shadow: 28px 0 0 #3c2c26;
  width: 7px;
  left: 22px;
  right: auto;
}
.judge-head u {
  position: absolute;
  left: 50%;
  top: 58px;
  width: 30px;
  height: 8px;
  transform: translateX(-50%);
  border-bottom: 3px solid rgba(82, 48, 37, .86);
  border-radius: 0 0 18px 18px;
  text-decoration: none;
}
.judge.is-speaking .judge-head u {
  animation: mouthTalk .22s ease-in-out infinite;
}
.judge.is-active {
  filter: drop-shadow(0 24px 26px rgba(0,0,0,.40)) drop-shadow(0 0 22px rgba(242,184,75,.22));
}
.judge-female .judge-head::before {
  inset: -12px -2px auto;
  height: 34px;
  border-radius: 28px 28px 12px 12px;
  background: linear-gradient(180deg, #332823, #1e1917);
}
.judge-female .judge-body {
  background: linear-gradient(90deg, #343a3d, #4b5454);
}
.judge-female .judge-body::before {
  background: #f2ead8;
}
.judge-male .judge-head::before {
  background: linear-gradient(180deg, #2b2520, #191715);
}
.judge-head i {
  opacity: .55;
}
.split-import {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
}
@keyframes mouthTalk {
  0%, 100% { height: 6px; border-bottom-width: 3px; transform: translateX(-50%) scaleX(.82); }
  50% { height: 15px; border-bottom-width: 7px; transform: translateX(-50%) scaleX(1.05); }
}
@media (max-width: 760px) {
  .split-import {
    grid-template-columns: 1fr;
  }
}


/* Collapsible simulator chrome, centered draw bowl, and subtle venue controls */
:root {
  --exam-panel-alpha: .58;
  --exam-panel-block-alpha: .64;
}
.topbar {
  gap: 12px;
  transition: height .2s ease, padding .2s ease, background .2s ease;
}
.brand-block {
  min-width: 0;
}
.brand-block h1 {
  white-space: nowrap;
}
.chrome-toggle {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.10);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.16);
  font-size: 12px;
  line-height: 1;
}
.topbar-toggle {
  position: absolute;
  left: 50%;
  bottom: -13px;
  z-index: 25;
  transform: translateX(-50%);
}
body.topbar-collapsed {
  --topbar-height: 32px;
}
body.topbar-collapsed .topbar {
  height: var(--topbar-height);
  padding: 4px max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left));
  justify-content: center;
  background: rgba(17, 19, 20, .44);
}
body.topbar-collapsed .brand-block,
body.topbar-collapsed .mode-tabs {
  display: none;
}
.exam-panel {
  background: rgba(13, 16, 16, var(--exam-panel-alpha));
  transition: width .22s ease, opacity .2s ease, background .2s ease;
}
.exam-panel .panel-block {
  background: rgba(18, 22, 22, var(--exam-panel-block-alpha));
}
.panel-toggle {
  position: absolute;
  left: -13px;
  top: 50%;
  z-index: 25;
  margin: 0;
  transform: translateY(-50%);
  background: rgba(17,19,20,.74);
}
.exam-panel.is-collapsed {
  width: 34px;
  padding: 6px;
  overflow: visible;
}
.exam-panel.is-collapsed > :not(.panel-toggle) {
  display: none !important;
}
.exam-panel.is-collapsed .panel-toggle {
  left: -13px;
}
.panel-controls {
  padding: 10px;
}
.compact-range {
  gap: 8px;
}
.compact-range input {
  padding: 0;
}
.stage-floor {
  justify-content: center;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.lottery-wrap {
  width: min(54vw, 620px);
}
.csv-only-layout {
  max-width: 760px;
}
.csv-import-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.primary-file {
  background: var(--amber);
  color: #111314;
  border-color: rgba(0,0,0,.12);
}
.inline-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.inline-check input {
  width: auto;
  accent-color: var(--teal);
}

@media (max-width: 980px) {
  .brand-block h1 {
    font-size: 16px;
  }
  .lottery-wrap {
    width: min(52vw, 500px);
    min-width: 240px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .lottery-wrap {
    width: min(46vw, 420px);
  }
  .exam-panel.is-collapsed {
    width: 44px;
  }
}


/* Compact vivid exam HUD refinement */
:root {
  --exam-panel-alpha: .28;
  --exam-panel-block-alpha: .36;
}
button,
.file-button {
  position: relative;
  background-image: linear-gradient(180deg, rgba(255,255,255,.26), rgba(0,0,0,.08));
  box-shadow: 0 7px 0 rgba(0,0,0,.26), 0 16px 28px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.35);
  transform: translateY(0);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
button:hover,
.file-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 0 rgba(0,0,0,.26), 0 20px 34px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.38);
}
button:active,
.file-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0,0,0,.28), 0 10px 18px rgba(0,0,0,.24), inset 0 2px 6px rgba(0,0,0,.16);
}
button.quiet {
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
}
.tab.is-active,
.timer-actions button.is-selected {
  background: linear-gradient(180deg, #72d0bf, #3f9f92);
  color: #06110f;
  box-shadow: 0 7px 0 rgba(12,82,74,.65), 0 16px 28px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.46);
}
.hand-button {
  background: radial-gradient(circle at 35% 18%, #ffe39a, #f2b84b 55%, #bc7c22);
  box-shadow: 0 9px 0 #7e4f15, 0 22px 38px rgba(0,0,0,.36), inset 0 2px rgba(255,255,255,.46);
}
.exam-panel {
  gap: 6px;
  padding: 8px;
  overflow: hidden;
  font-size: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.26), inset 0 1px rgba(255,255,255,.12);
}
.exam-panel .panel-block {
  padding: 8px 9px;
  box-shadow: 0 10px 28px rgba(0,0,0,.16), inset 0 1px rgba(255,255,255,.10);
}
.exam-panel .panel-controls {
  padding: 6px 8px;
}
.exam-panel label,
.exam-panel .stat-row,
.exam-panel .judge-speech {
  font-size: 11px;
}
.exam-panel select,
.exam-panel input {
  padding: 7px 8px;
  min-height: 32px;
}
.exam-panel button {
  min-height: 30px;
  padding: 6px 8px;
  font-size: 12px;
}
.license-strip {
  align-items: center;
  font-size: 11px;
}
.stat-row {
  margin-top: 6px;
}
.stat-row b {
  font-size: 15px;
}
.question-block h2 {
  min-height: 48px;
  max-height: 78px;
  overflow: hidden;
  font-size: clamp(16px, 1.55vw, 23px);
}
.answer-text {
  max-height: 138px;
  overflow: auto;
  padding: 8px;
}
.timer-display {
  font-size: clamp(34px, 4.4vw, 58px);
  padding: 2px 0 6px;
}
.timer-actions,
.question-actions {
  gap: 6px;
}
.rating-block {
  gap: 6px;
}
.panel-toggle {
  margin-bottom: 5px;
}
.topbar h1 {
  font-size: clamp(18px, 2vw, 24px);
}

@media (orientation: landscape) and (max-height: 520px) {
  .exam-panel {
    gap: 4px;
    padding: 5px;
  }
  .exam-panel .panel-block {
    padding: 6px 7px;
  }
  .panel-controls {
    padding: 4px 6px;
  }
  .question-block h2 {
    min-height: 34px;
    max-height: 54px;
    font-size: 14px;
  }
  .timer-display {
    font-size: 32px;
    padding: 0 0 3px;
  }
  .exam-panel button {
    min-height: 27px;
    padding: 4px 6px;
    font-size: 11px;
  }
  .rating-block {
    grid-template-columns: repeat(4, 1fr);
  }
}


/* Review-flow polish: flat draw control, stable canvas, readable prompts */
.topbar .brand-block .eyebrow {
  display: none;
}
.brand-block {
  display: flex;
  align-items: center;
}
.hand-button,
.hand-button:hover,
.hand-button:active,
.hand-button.is-drawing {
  background: #f2b84b;
  background-image: none;
  color: #111314;
  box-shadow: none;
  filter: none;
  animation: none;
  transform: translateX(-50%);
  transition: background-color .15s ease, filter .15s ease;
}
.hand-button:hover {
  filter: brightness(1.03);
}
.hand-button:active {
  filter: brightness(.96);
}
.question-block h2 {
  min-height: 92px;
  max-height: 152px;
  overflow: auto;
  align-items: flex-start;
  padding: 4px 0;
  font-size: var(--question-font-size, clamp(15px, 1.5vw, 22px));
  line-height: 1.34;
  scrollbar-width: thin;
}
.question-block h2.is-long {
  line-height: 1.42;
}
.timer-block {
  padding-top: 7px;
  padding-bottom: 7px;
}
.exam-panel .question-block {
  min-height: 238px;
}

@media (orientation: landscape) and (max-height: 520px) {
  .question-block h2 {
    min-height: 58px;
    max-height: 96px;
    font-size: var(--question-font-size, 14px);
  }
  .answer-text {
    min-height: 74px;
    max-height: 112px;
    font-size: 11px;
    line-height: 1.38;
  }
  .exam-panel .question-block {
    min-height: 190px;
  }
}


/* Single-deck question bank and output-mode controls */
.deck-title-display {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.25;
  color: var(--paper);
}
.panel-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.deck-title-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  min-width: min(420px, 100%);
}
.manage-head {
  align-items: end;
  flex-wrap: wrap;
}
.csv-import-box {
  align-items: stretch;
}
.card-row small {
  color: var(--muted);
}
.card-form label textarea {
  min-height: 94px;
}

@media (max-width: 760px) {
  .deck-title-editor {
    grid-template-columns: 1fr;
  }
}

/* Exam scoring and clearer problem-bank stats */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}
.stat-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 7px;
  background: rgba(255,255,255,.055);
  text-align: center;
}
.stat-row small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}
.stat-row b {
  color: var(--amber);
  font-size: 20px;
  line-height: 1;
}
.exam-finish-block {
  padding: 10px;
}
.finish-exam-button {
  width: 100%;
  background: linear-gradient(180deg, #f2c15d, #d6962e);
  color: #111314;
  border-color: rgba(255,255,255,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 8px 18px rgba(0,0,0,.24);
}
.exam-result-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5, 7, 7, .62);
  backdrop-filter: blur(6px);
}
.exam-result-card {
  position: relative;
  width: min(520px, calc(100vw - 36px));
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03)),
    rgba(20, 24, 24, .96);
  box-shadow: 0 28px 80px rgba(0,0,0,.52);
  text-align: center;
}
.exam-result-card.is-pass {
  border-color: rgba(242,184,75,.45);
  box-shadow: 0 30px 90px rgba(0,0,0,.56), 0 0 34px rgba(242,184,75,.18);
}
.exam-result-card.is-fail {
  border-color: rgba(231,111,81,.35);
}
.exam-result-card > strong {
  color: var(--amber);
  font-size: clamp(44px, 9vw, 78px);
  line-height: 1;
}
.exam-result-card p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
.result-status {
  font-size: 17px !important;
  font-weight: 850;
}
.modal-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.09);
  color: var(--text);
}
.result-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.result-breakdown span {
  padding: 6px 7px;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chrome-toggle {
  width: 26px !important;
  min-width: 26px !important;
  height: 26px !important;
  min-height: 26px !important;
  padding: 0 !important;
}

.purchase-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 7, .66);
  backdrop-filter: blur(8px);
}
.purchase-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 34px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(84, 182, 167, .30);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(84, 182, 167, .10), rgba(255,255,255,.03)),
    rgba(20, 24, 24, .97);
  box-shadow: 0 30px 86px rgba(0,0,0,.56);
}
.agreement-box {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(232, 236, 228, .16);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}
.agreement-box p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.check-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}
.check-line input {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}
.purchase-card h2 {
  font-size: 26px;
}
.purchase-card .button-row {
  flex-wrap: wrap;
}
.purchase-card .button-row button {
  flex: 1 1 180px;
}
.app-version {
  position: fixed;
  z-index: 35;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(6px, env(safe-area-inset-bottom));
  color: rgba(243, 244, 238, .46);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}
.manual-corner-link {
  position: fixed;
  z-index: 45;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(6px, env(safe-area-inset-bottom));
  padding: 5px 8px;
  border: 1px solid rgba(232, 236, 228, .18);
  border-radius: 7px;
  background: rgba(17, 19, 20, .58);
  color: rgba(243, 244, 238, .72);
  font-size: 11px;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(10px);
}
.manual-corner-link:hover {
  color: var(--paper);
  background: rgba(17, 19, 20, .76);
}

@media (max-width: 760px) {
  .brand-logo strong { font-size: 22px; }
  .brand-logo span { font-size: 10px; }
  .purchase-modal { padding: 10px; }
  .purchase-card {
    width: min(100%, calc(100vw - 20px));
    padding: 18px;
  }
}

/* v16: non-scrolling compact settings dashboard */
#view-settings {
  overflow: hidden !important;
  padding-top: var(--topbar-height);
}
#view-settings .settings-grid {
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
  padding: 10px 44px 30px 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
#view-settings .settings-band {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
#view-settings .section-head {
  align-items: flex-start;
  min-height: 0;
}
#view-settings h2 {
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.18;
}
#view-settings .eyebrow {
  font-size: 10px;
}
#view-settings .input-layout,
#view-settings .link-grid {
  gap: 7px;
  min-height: 0;
}
#view-settings label {
  gap: 4px;
  font-size: 11px;
}
#view-settings input,
#view-settings select {
  min-height: 32px;
  padding: 7px 9px;
  font-size: 12px;
}
#view-settings input[type="range"] {
  min-height: 26px;
  padding: 0;
}
#view-settings button {
  min-height: 31px;
  padding: 6px 8px;
  font-size: 12px;
}
#view-settings .button-row {
  gap: 6px;
}
#view-settings .button-row button {
  flex: 1 1 92px;
}
#view-settings .notice {
  font-size: 11px;
  line-height: 1.34;
}
#view-settings .license-status-box {
  padding: 8px 10px;
}
#view-settings .license-status-box span {
  font-size: 10px;
}
#view-settings .license-status-box strong {
  font-size: 12px;
  line-height: 1.3;
}
#view-settings .small-link-row a,
#view-settings .link-grid a {
  font-size: 12px;
  line-height: 1.25;
}
#view-settings .inline-check {
  min-height: 26px;
}
.community-board-band .section-head {
  gap: 8px;
}
.community-board-band .mini-action {
  flex: 0 0 auto;
  min-width: 68px;
  max-width: 88px;
}
.board-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  padding-right: 2px;
}
.board-empty {
  border: 1px dashed rgba(243, 238, 225, 0.18);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.board-post {
  border: 1px solid rgba(243, 238, 225, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 0;
  display: grid;
  overflow: hidden;
}
.board-post.is-pinned {
  border-color: rgba(117, 196, 181, 0.45);
  background: rgba(117, 196, 181, 0.08);
}
.board-post summary {
  min-height: 34px;
  padding: 8px 30px 8px 10px;
  cursor: pointer;
  list-style: none;
  position: relative;
  display: flex;
  align-items: center;
}
.board-post summary::-webkit-details-marker {
  display: none;
}
.board-post summary::after {
  content: "+";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 800;
}
.board-post[open] summary::after {
  content: "-";
}
.board-post-body {
  border-top: 1px solid rgba(243, 238, 225, 0.1);
  display: grid;
  gap: 5px;
  padding: 7px 9px 8px;
}
.board-post-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--accent);
  font-size: 10px;
}
.board-post strong {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.board-post p,
.board-answer {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.board-answer {
  border-top: 1px solid rgba(243, 238, 225, 0.12);
  padding-top: 5px;
}
.board-answer b {
  color: var(--text);
  margin-right: 6px;
}
.board-post small {
  color: rgba(243, 238, 225, 0.52);
  font-size: 10px;
}
.board-form {
  display: grid;
  gap: 6px;
}
#view-settings .board-form input,
#view-settings .board-form textarea {
  width: 100%;
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 7px 9px;
  font: inherit;
  font-size: 12px;
  resize: none;
}
#view-settings .board-form textarea {
  min-height: 54px;
  max-height: 72px;
}
.fullscreen-nav[aria-pressed="true"] {
  background: linear-gradient(180deg, #f2c15d, #d6962e);
  color: #111314;
}

/* v17: tighter mobile landscape framing */
.app-shell,
.view,
.arena-grid {
  width: 100svw;
  max-width: 100vw;
}

@media (orientation: landscape) and (max-height: 620px) {
  #view-settings .settings-grid {
    padding: 7px 42px 24px 7px;
    gap: 7px;
  }
  #view-settings .settings-band {
    padding: 8px;
    gap: 5px;
  }
  #view-settings h2 { font-size: 15px; }
  #view-settings .notice { font-size: 10px; line-height: 1.25; }
  #view-settings .license-status-box { padding: 7px 8px; }
  #view-settings input,
  #view-settings select,
  #view-settings button {
    min-height: 28px;
    padding: 5px 7px;
  }
  .board-list { gap: 5px; }
  .board-post summary { min-height: 30px; padding: 6px 28px 6px 8px; }
  .board-post-body { padding: 6px 8px 7px; gap: 4px; }
  .board-post p,
  .board-answer,
  .board-empty { font-size: 10px; line-height: 1.28; }
  #view-settings .board-form textarea { min-height: 42px; max-height: 54px; }
}

@media (orientation: landscape) and (max-width: 940px) and (max-height: 520px) {
  :root { --topbar-height: 50px; }
  .topbar {
    height: var(--topbar-height);
    padding: 6px calc(8px + env(safe-area-inset-right)) 6px calc(8px + env(safe-area-inset-left));
    gap: 6px;
  }
  .brand-logo strong { font-size: 18px; }
  .brand-logo span { font-size: 9px; }
  .mode-tabs { gap: 4px; }
  .tab,
  .fullscreen-nav {
    min-width: 0;
    min-height: 30px;
    padding: 5px 7px;
    font-size: 11px;
  }
  .judge-row {
    height: 44svh;
    padding-top: calc(var(--topbar-height) + 2px);
    gap: clamp(8px, 4vw, 28px);
  }
  .judge {
    width: clamp(82px, 12vw, 124px);
    height: 170px;
    transform: scale(.66);
  }
  .stage-floor {
    inset: 42svh 0 0;
    padding-left: calc(8px + env(safe-area-inset-left)) !important;
    padding-right: calc(47vw + env(safe-area-inset-right)) !important;
    justify-content: center;
  }
  .lottery-wrap {
    width: min(42vw, 340px);
    min-width: 168px;
  }
  .hand-button {
    min-width: 136px;
    min-height: 30px;
    padding: 6px 8px;
    font-size: 11px;
  }
  .exam-panel {
    top: calc(var(--topbar-height) + 4px);
    right: calc(4px + env(safe-area-inset-right));
    bottom: calc(4px + env(safe-area-inset-bottom));
    width: min(360px, 45vw);
    padding: 5px;
    gap: 4px;
  }
  .exam-panel .panel-block {
    padding: 5px 6px;
  }
  .question-block h2 {
    min-height: 42px;
    max-height: 68px;
    font-size: var(--question-font-size, 13px);
  }
  .answer-text {
    min-height: 82px;
    max-height: 118px;
    font-size: 10.5px;
    line-height: 1.35;
  }
  .exam-panel .question-block {
    min-height: 178px;
  }
  .timer-display {
    font-size: 30px;
    padding: 0 0 3px;
  }
}
/* SEO_CONTENT_CSS_START */
/* SEO content pages */
.start-card h1 { font-size: clamp(26px, 5vw, 42px); line-height: 1.14; }
.seo-content {
  width: 100%;
  background: #111614;
  color: var(--text);
  padding: 32px max(18px, env(safe-area-inset-left)) 42px max(18px, env(safe-area-inset-right));
}
.seo-inner,
.seo-page {
  width: min(1040px, 100%);
  margin: 0 auto;
}
.seo-content h2,
.seo-page h1,
.seo-page h2 {
  letter-spacing: 0;
  line-height: 1.22;
}
.seo-content h2 { margin: 6px 0 10px; font-size: clamp(22px, 3vw, 34px); }
.seo-content p,
.seo-page p,
.seo-page li { color: rgba(243, 244, 238, .76); line-height: 1.68; }
.seo-keyword-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.seo-keyword-grid article,
.seo-page-section {
  border: 1px solid rgba(232, 236, 228, .14);
  border-radius: 8px;
  background: rgba(255, 255, 255, .045);
  padding: 16px;
}
.seo-keyword-grid h3 { margin: 0 0 6px; color: var(--paper); font-size: 16px; }
.seo-cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.seo-cta-row a,
.seo-page .home-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  color: var(--paper);
  text-decoration: none;
  font-weight: 800;
}
.seo-page-body {
  min-height: 100svh;
  background: radial-gradient(circle at 15% 0%, rgba(99, 192, 177, .16), transparent 28rem), linear-gradient(135deg, #111314, #1b2020 58%, #151615);
}
.seo-page { padding: 42px 18px 68px; }
.seo-page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 16px; }
.seo-page h1 { margin: 4px 0 10px; font-size: clamp(32px, 5vw, 54px); color: var(--text); }
.seo-page-section { margin-top: 12px; }
.seo-page-section h2 { margin: 0 0 8px; font-size: 22px; color: var(--paper); }
.seo-page-section ol { margin: 0; padding-left: 1.25rem; }
@media (max-width: 780px) {
  .seo-keyword-grid { grid-template-columns: 1fr; }
  .seo-page-header { display: grid; }
}
/* SEO_CONTENT_CSS_END */
/* Inconspicuous admin access in settings notice card */
#view-settings .official-notice-band {
  position: relative;
}
#view-settings .admin-corner-link {
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  opacity: .24;
  font-size: 10px;
  background: rgba(255, 255, 255, .035);
  border-color: rgba(232, 236, 228, .10);
  color: rgba(243, 244, 238, .45);
}
#view-settings .admin-corner-link:hover,
#view-settings .admin-corner-link:focus-visible {
  opacity: .82;
  color: var(--paper);
  border-color: rgba(84, 182, 167, .42);
}

/* v30: mobile viewport and fullscreen guard */
body.app-body {
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
}
body.app-body .app-shell {
  width: var(--app-fit-width, var(--app-width, 100vw));
  max-width: none;
  height: var(--app-fit-height, var(--app-height, 100dvh));
  min-height: var(--app-fit-height, var(--app-height, 100dvh));
  transform: scale(var(--app-scale, 1));
  transform-origin: left top;
}
body.app-body .view,
body.app-body .arena-grid {
  width: var(--app-fit-width, var(--app-width, 100vw));
  max-width: none;
  height: var(--app-fit-height, var(--app-height, 100dvh));
  min-height: var(--app-fit-height, var(--app-height, 100dvh));
}
body.app-body #view-settings .settings-grid {
  height: calc(var(--app-fit-height, var(--app-height, 100dvh)) - var(--topbar-height));
}
body.app-body .start-gate {
  width: var(--app-width, 100vw);
  min-height: var(--app-height, 100dvh);
}
body.app-body .exam-panel {
  max-height: calc(var(--app-fit-height, var(--app-height, 100dvh)) - var(--topbar-height) - max(14px, env(safe-area-inset-bottom)));
}
body.app-body.is-mobile-device {
  touch-action: manipulation;
}
body.app-body.is-mobile-device .fullscreen-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.app-body.is-mobile-device .start-card {
  max-height: calc(var(--app-height, 100dvh) - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
  overflow: auto;
}
body.app-body.is-windowed-mobile .start-card::after {
  content: "모바일은 시작 버튼을 누르면 주소창과 하단 버튼을 최대한 숨겨 전체화면으로 전환합니다.";
  display: block;
  margin-top: 14px;
  color: rgba(243, 244, 238, .72);
  font-size: 12px;
  line-height: 1.45;
}
body.seo-page-body {
  height: auto;
  overflow: auto;
}

@media (orientation: landscape) and (max-width: 940px) and (max-height: 560px) {
  body.app-body.is-mobile-device {
    --topbar-height: 44px;
  }
  body.app-body.is-mobile-device .topbar {
    height: var(--topbar-height);
    padding: 5px calc(7px + env(safe-area-inset-right)) 5px calc(7px + env(safe-area-inset-left));
    gap: 5px;
  }
  body.app-body.is-mobile-device .brand-logo strong {
    font-size: 17px;
  }
  body.app-body.is-mobile-device .brand-logo span {
    font-size: 9px;
  }
  body.app-body.is-mobile-device .mode-tabs {
    gap: 4px;
  }
  body.app-body.is-mobile-device .tab,
  body.app-body.is-mobile-device .fullscreen-nav {
    min-width: 0;
    min-height: 29px;
    padding: 5px 6px;
    font-size: 10px;
  }
  body.app-body.is-mobile-device .chrome-toggle {
    width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    font-size: 11px;
  }
  body.app-body.is-mobile-device .topbar-toggle {
    bottom: -10px;
  }
  body.app-body.is-mobile-device .judge-row {
    height: 42%;
    padding-top: calc(var(--topbar-height) + 2px);
  }
  body.app-body.is-mobile-device .judge {
    width: clamp(78px, 11vw, 116px);
    height: 164px;
    transform: scale(.62);
  }
  body.app-body.is-mobile-device .stage-floor {
    inset: 39% 0 0;
    padding-left: calc(6px + env(safe-area-inset-left)) !important;
    padding-right: calc(min(330px, 43vw) + env(safe-area-inset-right)) !important;
  }
  body.app-body.is-mobile-device .lottery-wrap {
    width: min(39vw, 330px);
    min-width: 174px;
  }
  body.app-body.is-mobile-device .hand-button {
    min-width: 128px;
    min-height: 30px;
    padding: 6px 8px;
    font-size: 11px;
  }
  body.app-body.is-mobile-device .exam-panel {
    top: calc(var(--topbar-height) + 3px);
    right: calc(3px + env(safe-area-inset-right));
    bottom: calc(3px + env(safe-area-inset-bottom));
    width: min(334px, 43vw);
    padding: 4px;
    gap: 4px;
  }
  body.app-body.is-mobile-device .exam-panel .panel-block {
    padding: 5px 6px;
  }
  body.app-body.is-mobile-device .panel-controls {
    padding: 4px 6px;
  }
  body.app-body.is-mobile-device .question-block h2 {
    min-height: 38px;
    max-height: 66px;
    font-size: var(--question-font-size, 12px);
    line-height: 1.28;
  }
  body.app-body.is-mobile-device .answer-text {
    min-height: 96px;
    max-height: calc(var(--app-fit-height, var(--app-height, 100dvh)) - var(--topbar-height) - 210px);
    font-size: 10.5px;
    line-height: 1.35;
  }
  body.app-body.is-mobile-device .timer-display {
    font-size: 28px;
    padding: 0 0 2px;
  }
  body.app-body.is-mobile-device .timer-actions,
  body.app-body.is-mobile-device .rating-block,
  body.app-body.is-mobile-device .question-actions {
    gap: 4px;
  }
}

/* v31: dedicated mobile arena layout */
body.app-body.is-mobile-layout {
  --topbar-height: 42px;
}
body.app-body.is-mobile-layout .app-shell,
body.app-body.is-mobile-layout .view,
body.app-body.is-mobile-layout .arena-grid {
  width: var(--app-width, 100vw);
  max-width: 100vw;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  transform: none !important;
}
body.app-body.is-mobile-layout .topbar {
  height: var(--topbar-height);
  padding: 4px calc(6px + env(safe-area-inset-right)) 4px calc(6px + env(safe-area-inset-left));
  gap: 6px;
}
body.app-body.is-mobile-layout .brand-logo strong {
  font-size: 17px;
  line-height: 1;
}
body.app-body.is-mobile-layout .brand-logo span {
  display: none;
}
body.app-body.is-mobile-layout .mode-tabs {
  margin-left: auto;
  gap: 4px;
}
body.app-body.is-mobile-layout .tab,
body.app-body.is-mobile-layout .fullscreen-nav {
  min-width: 0;
  min-height: 30px;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
}
body.app-body.is-mobile-layout .chrome-toggle,
body.app-body.is-mobile-layout .panel-controls {
  display: none !important;
}
body.app-body.is-mobile-layout.topbar-collapsed .topbar {
  height: var(--topbar-height);
  justify-content: space-between;
}
body.app-body.is-mobile-layout.topbar-collapsed .brand-block,
body.app-body.is-mobile-layout.topbar-collapsed .mode-tabs {
  display: flex !important;
}
body.app-body.is-mobile-layout #view-arena {
  padding-top: 0;
  overflow: hidden;
}
body.app-body.is-mobile-layout .arena-grid {
  display: grid;
  grid-template-columns: minmax(0, 58%) minmax(258px, 42%);
  padding-top: var(--topbar-height);
}
body.app-body.is-mobile-layout .exam-stage {
  position: relative;
  inset: auto;
  min-width: 0;
  height: calc(var(--app-height, 100dvh) - var(--topbar-height));
  border-right: 1px solid rgba(232, 236, 228, .14);
}
body.app-body.is-mobile-layout .judge-row {
  position: absolute;
  inset: 0 0 auto;
  height: 38%;
  padding: 2px 6px 0;
  gap: clamp(0px, 2.4vw, 12px);
  align-items: end;
}
body.app-body.is-mobile-layout .judge {
  width: clamp(68px, 12vw, 92px);
  height: 158px;
  transform: scale(.58);
}
body.app-body.is-mobile-layout .judge-center {
  transform: scale(.64);
}
body.app-body.is-mobile-layout .stage-floor {
  position: absolute;
  inset: 35% 0 0;
  padding: 0 7px 8px !important;
  justify-content: center;
  align-items: center;
  gap: 0;
}
body.app-body.is-mobile-layout .stage-floor::before,
body.app-body.is-mobile-layout .candidate-mark {
  display: none !important;
}
body.app-body.is-mobile-layout .lottery-wrap {
  width: min(94%, 330px);
  min-width: 0;
  max-height: 100%;
}
body.app-body.is-mobile-layout #lotteryCanvas {
  touch-action: none;
}
body.app-body.is-mobile-layout .hand-button,
body.app-body.is-mobile-layout .hand-button:hover,
body.app-body.is-mobile-layout .hand-button:active {
  min-width: 132px;
  min-height: 32px;
  bottom: 0;
  padding: 6px 10px;
  font-size: 12px;
}
body.app-body.is-mobile-layout .exam-panel {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  width: auto;
  height: calc(var(--app-height, 100dvh) - var(--topbar-height));
  max-height: none;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 4px;
  padding: 4px calc(4px + env(safe-area-inset-right)) 4px 4px;
  border-radius: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}
body.app-body.is-mobile-layout .exam-panel.is-collapsed {
  width: auto;
  padding: 4px calc(4px + env(safe-area-inset-right)) 4px 4px;
  overflow: hidden;
}
body.app-body.is-mobile-layout .exam-panel.is-collapsed > .panel-block {
  display: block !important;
}
body.app-body.is-mobile-layout .exam-panel.is-collapsed > .question-block {
  display: grid !important;
}
body.app-body.is-mobile-layout .exam-panel.is-collapsed > .panel-controls {
  display: none !important;
}
body.app-body.is-mobile-layout .exam-panel .panel-block {
  min-width: 0;
  padding: 5px 6px;
  border-radius: 6px;
}
body.app-body.is-mobile-layout .row-between {
  gap: 5px;
}
body.app-body.is-mobile-layout .panel-label,
body.app-body.is-mobile-layout .judge-speech,
body.app-body.is-mobile-layout .exam-panel label {
  font-size: 10px;
  line-height: 1.25;
}
body.app-body.is-mobile-layout .deck-title-display {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
}
body.app-body.is-mobile-layout .stat-row {
  gap: 3px;
  margin-top: 5px;
}
body.app-body.is-mobile-layout .stat-row span {
  padding: 4px 3px;
  border-radius: 5px;
}
body.app-body.is-mobile-layout .stat-row small {
  font-size: 9px;
}
body.app-body.is-mobile-layout .stat-row b {
  font-size: 15px;
}
body.app-body.is-mobile-layout .question-block {
  display: grid;
  grid-template-rows: auto minmax(42px, auto) minmax(0, 1fr) auto;
  min-height: 0 !important;
  overflow: hidden;
}
body.app-body.is-mobile-layout .question-block h2 {
  min-height: 38px;
  max-height: 68px;
  overflow: auto;
  padding: 2px 0;
  font-size: var(--question-font-size, 12px);
  line-height: 1.28;
}
body.app-body.is-mobile-layout .answer-text {
  min-height: 42px;
  max-height: 76px;
  overflow: auto;
  font-size: 10px;
  line-height: 1.35;
}
body.app-body.is-mobile-layout .question-actions,
body.app-body.is-mobile-layout .timer-actions,
body.app-body.is-mobile-layout .rating-block {
  gap: 4px;
}
body.app-body.is-mobile-layout .exam-panel button {
  min-height: 28px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 10px;
}
body.app-body.is-mobile-layout .timer-block {
  padding-top: 4px;
  padding-bottom: 4px;
}
body.app-body.is-mobile-layout .timer-display {
  font-size: 26px;
  line-height: 1;
  padding: 0;
}
body.app-body.is-mobile-layout .rating-block {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
body.app-body.is-mobile-layout .exam-finish-block {
  padding: 4px 6px;
}
body.app-body.is-mobile-layout .finish-exam-button {
  min-height: 28px;
}
body.app-body.is-mobile-layout #view-cards,
body.app-body.is-mobile-layout #view-settings {
  height: var(--app-height, 100dvh);
  padding-top: var(--topbar-height);
  overflow: auto;
}
body.app-body.is-mobile-layout .cards-grid,
body.app-body.is-mobile-layout #view-settings .settings-grid {
  height: auto;
  min-height: calc(var(--app-height, 100dvh) - var(--topbar-height));
  display: block;
  padding: 8px;
  overflow: visible;
}
body.app-body.is-mobile-layout .editor-band,
body.app-body.is-mobile-layout .manage-band,
body.app-body.is-mobile-layout #view-settings .settings-band {
  margin-bottom: 8px;
}

@media (orientation: landscape) and (max-width: 760px) {
  body.app-body.is-mobile-layout {
    --topbar-height: 38px;
  }
  body.app-body.is-mobile-layout .arena-grid {
    grid-template-columns: minmax(0, 56%) minmax(248px, 44%);
  }
  body.app-body.is-mobile-layout .topbar {
    padding-top: 3px;
    padding-bottom: 3px;
  }
  body.app-body.is-mobile-layout .tab,
  body.app-body.is-mobile-layout .fullscreen-nav {
    min-height: 27px;
    padding-inline: 5px;
    font-size: 10px;
  }
  body.app-body.is-mobile-layout .brand-logo strong {
    font-size: 15px;
  }
  body.app-body.is-mobile-layout .judge {
    transform: scale(.52);
  }
  body.app-body.is-mobile-layout .judge-center {
    transform: scale(.58);
  }
  body.app-body.is-mobile-layout .stage-floor {
    inset: 34% 0 0;
  }
  body.app-body.is-mobile-layout .lottery-wrap {
    width: min(96%, 280px);
  }
  body.app-body.is-mobile-layout .exam-panel {
    gap: 3px;
    padding: 3px calc(3px + env(safe-area-inset-right)) 3px 3px;
  }
  body.app-body.is-mobile-layout .exam-panel .panel-block {
    padding: 4px 5px;
  }
  body.app-body.is-mobile-layout .question-block h2 {
    max-height: 58px;
    font-size: var(--question-font-size, 11px);
  }
  body.app-body.is-mobile-layout .answer-text {
    max-height: 60px;
  }
  body.app-body.is-mobile-layout .timer-display {
    font-size: 23px;
  }
}

/* v32: mobile-first side-rail interface */
body.app-body.is-mobile-layout {
  --mobile-rail-width: 58px;
  --topbar-height: 0px;
}
body.app-body.is-mobile-layout .topbar,
body.app-body.is-mobile-layout.topbar-collapsed .topbar {
  position: fixed;
  top: 0;
  right: auto;
  bottom: 0;
  left: 0;
  width: var(--mobile-rail-width);
  height: var(--app-height, 100dvh);
  padding: calc(5px + env(safe-area-inset-top)) 4px calc(5px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  border-right: 1px solid rgba(232, 236, 228, .16);
  border-bottom: 0;
  background: rgba(15, 18, 18, .86);
  backdrop-filter: blur(14px);
  overflow: hidden;
}
body.app-body.is-mobile-layout .brand-block,
body.app-body.is-mobile-layout.topbar-collapsed .brand-block {
  display: flex !important;
  width: 100%;
  justify-content: center;
}
body.app-body.is-mobile-layout .brand-logo {
  width: 100%;
  text-align: center;
}
body.app-body.is-mobile-layout .brand-logo strong {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.05;
  letter-spacing: 0;
}
body.app-body.is-mobile-layout .brand-logo span {
  display: none !important;
}
body.app-body.is-mobile-layout .mode-tabs,
body.app-body.is-mobile-layout.topbar-collapsed .mode-tabs {
  display: flex !important;
  flex: 1 1 auto;
  width: 100%;
  margin: 4px 0 0;
  flex-direction: column;
  gap: 5px;
}
body.app-body.is-mobile-layout .tab,
body.app-body.is-mobile-layout .fullscreen-nav {
  width: 100%;
  min-height: 40px;
  padding: 3px 2px;
  white-space: normal;
  border-radius: 7px;
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
}
body.app-body.is-mobile-layout .fullscreen-nav {
  margin-top: auto;
}
body.app-body.is-mobile-layout .arena-grid {
  padding-top: 0;
  padding-left: var(--mobile-rail-width);
  grid-template-columns: minmax(0, 52%) minmax(270px, 48%);
}
body.app-body.is-mobile-layout .exam-stage,
body.app-body.is-mobile-layout .exam-panel {
  height: var(--app-height, 100dvh);
}
body.app-body.is-mobile-layout .judge-row {
  height: 32%;
  padding: 0 4px;
  opacity: .82;
}
body.app-body.is-mobile-layout .judge {
  width: clamp(60px, 10vw, 84px);
  height: 152px;
  transform: scale(.5);
}
body.app-body.is-mobile-layout .judge-center {
  transform: scale(.56);
}
body.app-body.is-mobile-layout .stage-floor {
  inset: 30% 0 0;
  padding: 0 6px 7px !important;
}
body.app-body.is-mobile-layout .lottery-wrap {
  width: min(94%, 300px);
  aspect-ratio: 1 / 1;
}
body.app-body.is-mobile-layout .hand-button,
body.app-body.is-mobile-layout .hand-button:hover,
body.app-body.is-mobile-layout .hand-button:active {
  min-width: min(172px, 82%);
  min-height: 38px;
  bottom: 2px;
  padding: 8px 10px;
  font-size: 13px;
}
body.app-body.is-mobile-layout .exam-panel,
body.app-body.is-mobile-layout .exam-panel.is-collapsed {
  height: var(--app-height, 100dvh);
  padding: 5px calc(5px + env(safe-area-inset-right)) 5px 5px;
  gap: 5px;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}
body.app-body.is-mobile-layout .exam-panel .panel-block {
  padding: 6px 7px;
}
body.app-body.is-mobile-layout .question-block {
  grid-template-rows: auto minmax(48px, auto) minmax(0, 1fr) auto;
}
body.app-body.is-mobile-layout .question-block h2 {
  min-height: 46px;
  max-height: 84px;
  font-size: var(--question-font-size, 13px);
}
body.app-body.is-mobile-layout .answer-text {
  min-height: 50px;
  max-height: 98px;
  font-size: 10.5px;
}
body.app-body.is-mobile-layout .exam-panel button {
  min-height: 34px;
  padding: 6px 7px;
  font-size: 11px;
}
body.app-body.is-mobile-layout .timer-display {
  font-size: 30px;
}
body.app-body.is-mobile-layout .manual-corner-link {
  display: none;
}
body.app-body.is-mobile-layout #view-cards,
body.app-body.is-mobile-layout #view-settings {
  padding-top: 0;
  padding-left: var(--mobile-rail-width);
}
body.app-body.is-mobile-layout .cards-grid,
body.app-body.is-mobile-layout #view-settings .settings-grid {
  min-height: var(--app-height, 100dvh);
  padding: 7px;
}

@media (orientation: landscape) and (max-width: 760px) {
  body.app-body.is-mobile-layout {
    --mobile-rail-width: 52px;
  }
  body.app-body.is-mobile-layout .tab,
  body.app-body.is-mobile-layout .fullscreen-nav {
    min-height: 36px;
    font-size: 9.5px;
  }
  body.app-body.is-mobile-layout .arena-grid {
    grid-template-columns: minmax(0, 48%) minmax(264px, 52%);
  }
  body.app-body.is-mobile-layout .lottery-wrap {
    width: min(95%, 250px);
  }
  body.app-body.is-mobile-layout .hand-button,
  body.app-body.is-mobile-layout .hand-button:hover,
  body.app-body.is-mobile-layout .hand-button:active {
    min-height: 35px;
    font-size: 12px;
  }
  body.app-body.is-mobile-layout .exam-panel,
  body.app-body.is-mobile-layout .exam-panel.is-collapsed {
    padding: 4px calc(4px + env(safe-area-inset-right)) 4px 4px;
    gap: 4px;
  }
  body.app-body.is-mobile-layout .exam-panel .panel-block {
    padding: 5px 6px;
  }
  body.app-body.is-mobile-layout .question-block h2 {
    min-height: 40px;
    max-height: 66px;
    font-size: var(--question-font-size, 11.5px);
  }
  body.app-body.is-mobile-layout .answer-text {
    min-height: 42px;
    max-height: 70px;
    font-size: 10px;
  }
  body.app-body.is-mobile-layout .exam-panel button {
    min-height: 31px;
    font-size: 10px;
  }
  body.app-body.is-mobile-layout .timer-display {
    font-size: 25px;
  }
}

/* v33: resilient mobile workspace */
body.app-body.is-mobile-layout .exam-stage {
  overflow: hidden;
}
body.app-body.is-mobile-layout .judge-row {
  height: 50px;
  padding: 4px 6px 0;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 4vw, 30px);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.08));
}
body.app-body.is-mobile-layout .judge,
body.app-body.is-mobile-layout .judge-center {
  width: 44px;
  height: 44px;
  transform: none !important;
  animation: none;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.24));
}
body.app-body.is-mobile-layout .judge-head {
  left: 50%;
  top: 3px;
  width: 38px;
  height: 38px;
  transform: translateX(-50%);
  border-radius: 44% 44% 48% 48%;
}
body.app-body.is-mobile-layout .judge-head::before {
  inset: -4px 5px auto;
  height: 13px;
  border-radius: 14px 14px 5px 5px;
}
body.app-body.is-mobile-layout .judge-head::after {
  left: 10px;
  right: 10px;
  top: 20px;
  height: 2px;
  box-shadow: 0 8px 0 -1px rgba(76,51,40,.65);
}
body.app-body.is-mobile-layout .judge-head i {
  left: 9px;
  top: 17px;
  width: 18px;
  height: 7px;
  border-top-width: 1px;
  border-left-width: 1px;
  border-right-width: 1px;
}
body.app-body.is-mobile-layout .judge-head u,
body.app-body.is-mobile-layout .judge-body,
body.app-body.is-mobile-layout .judge-desk {
  display: none !important;
}
body.app-body.is-mobile-layout .stage-floor {
  inset: 50px 0 0;
  padding: 4px 6px 8px !important;
}
body.app-body.is-mobile-layout .lottery-wrap {
  width: min(96%, 310px);
  max-height: calc(var(--app-height, 100dvh) - 62px);
  aspect-ratio: 1 / 1;
}
body.app-body.is-mobile-layout .exam-panel,
body.app-body.is-mobile-layout .exam-panel.is-collapsed {
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-content: stretch;
  scrollbar-width: thin;
}
body.app-body.is-mobile-layout .exam-panel .panel-block {
  flex: 0 0 auto;
}
body.app-body.is-mobile-layout .question-block {
  flex: 1 0 118px;
  min-height: 112px !important;
}
body.app-body.is-mobile-layout .question-block h2 {
  min-height: 42px;
  max-height: 72px;
}
body.app-body.is-mobile-layout .answer-text {
  min-height: 44px;
  max-height: 88px;
}
body.app-body.is-mobile-layout #view-cards,
body.app-body.is-mobile-layout #view-settings {
  position: fixed;
  inset: 0 0 0 var(--mobile-rail-width);
  width: auto;
  height: var(--app-height, 100dvh);
  min-height: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
body.app-body.is-mobile-layout .cards-grid,
body.app-body.is-mobile-layout #view-settings .settings-grid {
  width: 100%;
  min-height: auto;
  height: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  align-content: start;
  gap: 8px;
  padding: 8px max(8px, env(safe-area-inset-right)) max(42px, env(safe-area-inset-bottom)) 8px;
  overflow: visible;
}
body.app-body.is-mobile-layout .manage-layout {
  grid-template-columns: 1fr;
}
body.app-body.is-mobile-layout .card-list {
  max-height: 32vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
body.app-body.is-mobile-layout .card-form textarea {
  min-height: 82px;
}
body.app-body.is-mobile-layout .settings-band,
body.app-body.is-mobile-layout .editor-band,
body.app-body.is-mobile-layout .manage-band {
  min-height: 0;
  padding: 9px;
}
body.app-body.is-mobile-layout .settings-band .section-head,
body.app-body.is-mobile-layout .editor-band .section-head,
body.app-body.is-mobile-layout .manage-band .section-head {
  gap: 8px;
}
body.app-body.is-mobile-layout .settings-band h2,
body.app-body.is-mobile-layout .editor-band h2,
body.app-body.is-mobile-layout .manage-band h2 {
  font-size: 16px;
}
body.app-body.is-mobile-layout .purchase-modal,
body.app-body.is-mobile-layout .exam-result-modal {
  left: var(--mobile-rail-width);
}

@media (orientation: landscape) and (max-height: 390px) {
  body.app-body.is-mobile-layout .judge-row {
    height: 42px;
    padding-top: 2px;
  }
  body.app-body.is-mobile-layout .judge,
  body.app-body.is-mobile-layout .judge-center {
    width: 36px;
    height: 36px;
  }
  body.app-body.is-mobile-layout .judge-head {
    width: 32px;
    height: 32px;
  }
  body.app-body.is-mobile-layout .judge-head::after {
    top: 17px;
  }
  body.app-body.is-mobile-layout .judge-head i {
    left: 8px;
    top: 14px;
    width: 15px;
  }
  body.app-body.is-mobile-layout .stage-floor {
    inset: 42px 0 0;
  }
  body.app-body.is-mobile-layout .lottery-wrap {
    width: min(96%, 240px);
    max-height: calc(var(--app-height, 100dvh) - 52px);
  }
  body.app-body.is-mobile-layout .question-block {
    flex-basis: 100px;
    min-height: 96px !important;
  }
  body.app-body.is-mobile-layout .question-block h2 {
    min-height: 36px;
    max-height: 58px;
  }
  body.app-body.is-mobile-layout .answer-text {
    min-height: 36px;
    max-height: 58px;
  }
  body.app-body.is-mobile-layout .timer-display {
    font-size: 22px;
  }
}

/* v34: portrait-first mobile interface */
.application-result {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(84, 182, 167, .35);
  border-radius: 8px;
  background: rgba(84, 182, 167, .13);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.45;
}

body.app-body.is-mobile-layout {
  --mobile-header-height: 58px;
  --mobile-nav-height: 66px;
  --mobile-rail-width: 0px;
  --topbar-height: 0px;
  font-size: 14px;
}

body.app-body.is-mobile-layout .portrait-guard {
  display: none !important;
}

body.app-body.is-mobile-layout,
body.app-body.is-mobile-layout .app-shell,
body.app-body.is-mobile-layout .view,
body.app-body.is-mobile-layout .arena-grid {
  width: var(--app-width, 100vw);
  max-width: 100vw;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  transform: none !important;
}

body.app-body.is-mobile-layout .app-shell {
  overflow: hidden;
}

body.app-body.is-mobile-layout .topbar,
body.app-body.is-mobile-layout.topbar-collapsed .topbar {
  position: fixed;
  z-index: 42;
  top: 0;
  right: 0;
  bottom: auto;
  left: 0;
  width: var(--app-width, 100vw);
  height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-right: 0;
  border-bottom: 1px solid rgba(232, 236, 228, .14);
  background: rgba(14, 17, 17, .88);
  backdrop-filter: blur(14px);
  overflow: visible;
}

body.app-body.is-mobile-layout .brand-block,
body.app-body.is-mobile-layout.topbar-collapsed .brand-block {
  display: flex !important;
  width: auto;
  min-width: 0;
  justify-content: flex-start;
}

body.app-body.is-mobile-layout .brand-logo {
  width: auto;
  min-width: 0;
  text-align: left;
}

body.app-body.is-mobile-layout .brand-logo strong {
  display: block;
  width: auto;
  overflow: visible;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0;
}

body.app-body.is-mobile-layout .brand-logo span {
  display: block !important;
  max-width: 52vw;
  overflow: hidden;
  color: var(--sage);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.app-body.is-mobile-layout .mode-tabs,
body.app-body.is-mobile-layout.topbar-collapsed .mode-tabs {
  position: fixed;
  z-index: 43;
  left: 0;
  right: 0;
  bottom: 0;
  width: var(--app-width, 100vw);
  height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  margin: 0;
  padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid rgba(232, 236, 228, .14);
  background: rgba(13, 16, 16, .92);
  backdrop-filter: blur(14px);
}

body.app-body.is-mobile-layout .tab,
body.app-body.is-mobile-layout .fullscreen-nav {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 6px 4px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  box-shadow: none;
}

body.app-body.is-mobile-layout .fullscreen-nav {
  margin-top: 0;
}

body.app-body.is-mobile-layout .chrome-toggle,
body.app-body.is-mobile-layout .panel-controls,
body.app-body.is-mobile-layout .manual-corner-link {
  display: none !important;
}

body.app-body.is-mobile-layout #view-arena,
body.app-body.is-mobile-layout #view-cards,
body.app-body.is-mobile-layout #view-settings {
  position: relative;
  inset: auto;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

body.app-body.is-mobile-layout .arena-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: auto;
  min-height: var(--app-height, 100dvh);
  padding: calc(var(--mobile-header-height) + env(safe-area-inset-top) + 10px) max(10px, env(safe-area-inset-right)) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px) max(10px, env(safe-area-inset-left));
}

body.app-body.is-mobile-layout .exam-stage {
  position: relative;
  inset: auto;
  width: 100%;
  min-width: 0;
  height: clamp(330px, 45vh, 430px);
  min-height: 330px;
  border: 1px solid rgba(232, 236, 228, .14);
  border-radius: 14px;
  overflow: hidden;
}

body.app-body.is-mobile-layout .judge-row {
  position: absolute;
  inset: 0 0 auto;
  height: 136px;
  padding: 10px 10px 0;
  align-items: end;
  justify-content: center;
  gap: clamp(18px, 7vw, 44px);
  opacity: .96;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.04));
}

body.app-body.is-mobile-layout .judge,
body.app-body.is-mobile-layout .judge-center {
  width: 86px;
  height: 126px;
  transform: none !important;
  animation: judgeIdle 5.2s ease-in-out infinite;
  filter: drop-shadow(0 12px 14px rgba(0,0,0,.32));
}

body.app-body.is-mobile-layout .judge-center {
  height: 132px;
}

body.app-body.is-mobile-layout .judge-head {
  left: 50%;
  top: 4px;
  width: 48px;
  height: 54px;
  transform: translateX(-50%);
  border-radius: 42% 42% 46% 46%;
}

body.app-body.is-mobile-layout .judge-head::before {
  inset: -7px 5px auto;
  height: 20px;
  border-radius: 18px 18px 7px 7px;
}

body.app-body.is-mobile-layout .judge-female .judge-head::before {
  inset: -9px -1px auto;
  height: 24px;
  border-radius: 22px 22px 10px 10px;
}

body.app-body.is-mobile-layout .judge-head::after {
  left: 14px;
  right: auto;
  top: 25px;
  width: 5px;
  height: 2px;
  box-shadow: 18px 0 0 #3c2c26;
}

body.app-body.is-mobile-layout .judge-head i {
  left: 12px;
  top: 23px;
  width: 24px;
  height: 8px;
  border-top-width: 1px;
  border-left-width: 1px;
  border-right-width: 1px;
}

body.app-body.is-mobile-layout .judge-head u {
  display: block !important;
  top: 39px;
  width: 20px;
  height: 6px;
  border-bottom-width: 2px;
}

body.app-body.is-mobile-layout .judge-body {
  display: block !important;
  top: 54px;
  width: 72px;
  height: 62px;
  border-radius: 22px 22px 8px 8px;
}

body.app-body.is-mobile-layout .judge-body::before {
  width: 20px;
  height: 42px;
}

body.app-body.is-mobile-layout .judge-body b {
  right: -8px;
  bottom: 10px;
  width: 30px;
  height: 8px;
}

body.app-body.is-mobile-layout .judge-desk {
  display: block !important;
  bottom: 0;
  width: 92px;
  height: 24px;
  border-radius: 7px 7px 3px 3px;
}

body.app-body.is-mobile-layout .judge-desk em {
  right: 12px;
  top: -6px;
  width: 26px;
  height: 17px;
}

body.app-body.is-mobile-layout .stage-floor {
  position: absolute;
  inset: 136px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px 12px !important;
}

body.app-body.is-mobile-layout .stage-floor::before,
body.app-body.is-mobile-layout .candidate-mark {
  display: none !important;
}

body.app-body.is-mobile-layout .lottery-wrap {
  width: min(92vw, 390px);
  min-width: 0;
  max-height: 100%;
  aspect-ratio: 13 / 8;
}

body.app-body.is-mobile-layout .hand-button,
body.app-body.is-mobile-layout .hand-button:hover,
body.app-body.is-mobile-layout .hand-button:active {
  min-width: min(210px, 82%);
  min-height: 46px;
  bottom: 6px;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 15px;
  box-shadow: none;
}

body.app-body.is-mobile-layout .exam-panel,
body.app-body.is-mobile-layout .exam-panel.is-collapsed {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  height: auto;
  max-height: none;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.app-body.is-mobile-layout .exam-panel.is-collapsed > .panel-block,
body.app-body.is-mobile-layout .exam-panel.is-collapsed > .question-block {
  display: block !important;
}

body.app-body.is-mobile-layout .exam-panel .panel-block,
body.app-body.is-mobile-layout .settings-band,
body.app-body.is-mobile-layout .editor-band,
body.app-body.is-mobile-layout .manage-band {
  min-width: 0;
  min-height: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(18, 22, 22, .82);
}

body.app-body.is-mobile-layout .panel-label,
body.app-body.is-mobile-layout .judge-speech,
body.app-body.is-mobile-layout .exam-panel label,
body.app-body.is-mobile-layout label,
body.app-body.is-mobile-layout .notice {
  font-size: 13px;
  line-height: 1.38;
}

body.app-body.is-mobile-layout .row-between,
body.app-body.is-mobile-layout .section-head,
body.app-body.is-mobile-layout .button-row,
body.app-body.is-mobile-layout .timer-actions,
body.app-body.is-mobile-layout .question-actions {
  gap: 8px;
}

body.app-body.is-mobile-layout .deck-title-display {
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.3;
}

body.app-body.is-mobile-layout .stat-row {
  gap: 6px;
  margin-top: 8px;
}

body.app-body.is-mobile-layout .stat-row span {
  padding: 7px 5px;
  border-radius: 8px;
}

body.app-body.is-mobile-layout .stat-row small {
  font-size: 10px;
}

body.app-body.is-mobile-layout .stat-row b {
  font-size: 18px;
}

body.app-body.is-mobile-layout .question-block {
  display: block;
  min-height: 0 !important;
  overflow: visible;
}

body.app-body.is-mobile-layout .question-block h2 {
  min-height: 78px;
  max-height: none;
  overflow: visible;
  padding: 4px 0;
  align-items: flex-start;
  font-size: var(--question-font-size, clamp(18px, 5vw, 24px));
  line-height: 1.36;
}

body.app-body.is-mobile-layout .answer-text {
  min-height: 128px;
  max-height: none;
  overflow: visible;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
}

body.app-body.is-mobile-layout .timer-display {
  font-size: clamp(38px, 11vw, 52px);
  padding: 4px 0 8px;
}

body.app-body.is-mobile-layout .rating-block {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.app-body.is-mobile-layout button,
body.app-body.is-mobile-layout .file-button {
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.2;
}

body.app-body.is-mobile-layout input,
body.app-body.is-mobile-layout select,
body.app-body.is-mobile-layout textarea {
  min-height: 44px;
  padding: 10px 11px;
  border-radius: 9px;
  font-size: 14px;
}

body.app-body.is-mobile-layout .cards-grid,
body.app-body.is-mobile-layout #view-settings .settings-grid {
  width: 100%;
  height: auto;
  min-height: var(--app-height, 100dvh);
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
  padding: calc(var(--mobile-header-height) + env(safe-area-inset-top) + 10px) max(10px, env(safe-area-inset-right)) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px) max(10px, env(safe-area-inset-left));
  overflow: visible;
}

body.app-body.is-mobile-layout .manage-layout,
body.app-body.is-mobile-layout .deck-title-editor,
body.app-body.is-mobile-layout .split-import {
  grid-template-columns: 1fr;
}

body.app-body.is-mobile-layout .card-list {
  max-height: 34vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

body.app-body.is-mobile-layout .card-form textarea {
  min-height: 112px;
}

body.app-body.is-mobile-layout .csv-import-box,
body.app-body.is-mobile-layout .purchase-card .button-row {
  display: grid;
  grid-template-columns: 1fr;
}

body.app-body.is-mobile-layout .official-link-list {
  padding-right: 24px;
}

body.app-body.is-mobile-layout .purchase-modal,
body.app-body.is-mobile-layout .exam-result-modal {
  left: 0;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

body.app-body.is-mobile-layout .purchase-card,
body.app-body.is-mobile-layout .exam-result-card {
  width: min(560px, 100%);
  max-height: calc(var(--app-height, 100dvh) - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
  overflow: auto;
  padding: 18px;
}

body.app-body.is-mobile-layout .seo-content {
  display: none;
}

body.app-body.is-mobile-layout .toast {
  right: max(10px, env(safe-area-inset-right));
  bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 10px);
  left: max(10px, env(safe-area-inset-left));
  max-width: none;
}

@media (orientation: portrait) and (max-width: 760px) {
  .portrait-guard {
    display: none !important;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body.app-body.is-mobile-layout {
    --mobile-header-height: 48px;
    --mobile-nav-height: 54px;
  }

  body.app-body.is-mobile-layout .brand-logo strong {
    font-size: 17px;
  }

  body.app-body.is-mobile-layout .brand-logo span {
    display: none !important;
  }

  body.app-body.is-mobile-layout .tab,
  body.app-body.is-mobile-layout .fullscreen-nav {
    min-height: 38px;
    font-size: 11px;
  }

  body.app-body.is-mobile-layout .arena-grid {
    display: grid;
    grid-template-columns: minmax(0, 48%) minmax(0, 52%);
    gap: 8px;
    height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  body.app-body.is-mobile-layout .exam-stage {
    height: auto;
    min-height: 0;
  }

  body.app-body.is-mobile-layout .judge-row {
    height: 98px;
    padding-top: 5px;
  }

  body.app-body.is-mobile-layout .judge,
  body.app-body.is-mobile-layout .judge-center {
    width: 68px;
    height: 98px;
  }

  body.app-body.is-mobile-layout .judge-head {
    width: 38px;
    height: 42px;
  }

  body.app-body.is-mobile-layout .judge-body {
    top: 42px;
    width: 56px;
    height: 46px;
  }

  body.app-body.is-mobile-layout .judge-desk {
    width: 72px;
    height: 18px;
  }

  body.app-body.is-mobile-layout .stage-floor {
    inset: 98px 0 0;
  }

  body.app-body.is-mobile-layout .lottery-wrap {
    width: min(94%, 280px);
    aspect-ratio: 1 / 1;
  }

  body.app-body.is-mobile-layout .exam-panel,
  body.app-body.is-mobile-layout .exam-panel.is-collapsed {
    max-height: calc(var(--app-height, 100dvh) - var(--mobile-header-height) - var(--mobile-nav-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.app-body.is-mobile-layout .question-block h2 {
    min-height: 48px;
    font-size: var(--question-font-size, 13px);
  }

  body.app-body.is-mobile-layout .answer-text {
    min-height: 68px;
    font-size: 11px;
  }

  body.app-body.is-mobile-layout button,
  body.app-body.is-mobile-layout .file-button {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* v35: mobile lottery fit and download feedback refinements */
body.app-body.is-mobile-layout .lottery-wrap {
  width: min(88vw, var(--lottery-fit-width, 300px));
  max-width: calc(100% - 8px);
  aspect-ratio: 13 / 8;
}

body.app-body.is-mobile-layout #lotteryCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

body.app-body.is-mobile-layout .stage-floor {
  overflow: visible;
}

@media (orientation: landscape) and (max-height: 520px) {
  body.app-body.is-mobile-layout .lottery-wrap {
    width: min(42vw, var(--lottery-fit-width, 250px));
    aspect-ratio: 13 / 8;
  }
}

/* v36: persistent CSV download notice */
.download-notice-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 7, .66);
  backdrop-filter: blur(8px);
}

.download-notice-card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(84, 182, 167, .30);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(84, 182, 167, .10), rgba(255,255,255,.03)),
    rgba(20, 24, 24, .97);
  box-shadow: 0 30px 86px rgba(0,0,0,.56);
}

.download-notice-card h2 {
  font-size: 24px;
}

.download-path-box {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

.download-path-box span {
  color: var(--sage);
  font-size: 12px;
  font-weight: 850;
}

.download-path-box strong {
  overflow-wrap: anywhere;
  color: var(--paper);
  font-size: 15px;
}

body.app-body.is-mobile-layout .download-notice-modal {
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

body.app-body.is-mobile-layout .download-notice-card {
  width: min(520px, 100%);
  max-height: calc(var(--app-height, 100dvh) - 20px);
  overflow: auto;
  padding: 18px;
}

/* v37: Kakao install guide and auto-start mode */
.install-guide-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 7, .74);
  backdrop-filter: blur(10px);
}

.install-guide-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  display: grid;
  gap: 13px;
  padding: 24px;
  border: 1px solid rgba(242, 184, 75, .34);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(242, 184, 75, .10), rgba(255,255,255,.03)),
    rgba(20, 24, 24, .97);
  box-shadow: 0 34px 92px rgba(0,0,0,.58);
}

.install-guide-card h2 {
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.22;
}

.install-step-list {
  margin: 0;
  padding-left: 1.25rem;
  color: rgba(243, 244, 238, .82);
  line-height: 1.65;
}

.install-step-list strong {
  color: var(--paper);
}

body.app-body.is-mobile-layout .install-guide-modal {
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

body.app-body.is-mobile-layout .install-guide-card {
  width: min(560px, 100%);
  max-height: calc(var(--app-height, 100dvh) - 20px);
  overflow: auto;
  padding: 18px;
}

/* v39: safer mobile top chrome for installed app/fullscreen transitions */
body.app-body.is-mobile-layout {
  --mobile-header-height: 64px;
}

body.app-body.is-mobile-layout .topbar,
body.app-body.is-mobile-layout.topbar-collapsed .topbar {
  min-height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-bottom: 10px;
  overflow: visible;
}

body.app-body.is-mobile-layout .brand-logo strong {
  line-height: 1.08;
}

body.app-body.is-mobile-layout .brand-logo span {
  line-height: 1.25;
}

body.app-body.is-mobile-layout .tab,
body.app-body.is-mobile-layout .fullscreen-nav {
  min-height: 46px;
}

@media (orientation: landscape) and (max-height: 520px) {
  body.app-body.is-mobile-layout {
    --mobile-header-height: 52px;
  }

  body.app-body.is-mobile-layout .topbar,
  body.app-body.is-mobile-layout.topbar-collapsed .topbar {
    padding-top: calc(7px + env(safe-area-inset-top));
    padding-bottom: 7px;
  }

  body.app-body.is-mobile-layout .tab,
  body.app-body.is-mobile-layout .fullscreen-nav {
    min-height: 40px;
  }
}
