:root {
  color-scheme: light;
  --paper: #f2f1ed;
  --surface: #faf9f5;
  --ink: #18181b;
  --muted: #626269;
  --line: rgba(24, 24, 27, 0.22);
  --blue: #2852d8;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.page { width: min(100%, 1400px); margin: auto; padding: 22px clamp(20px, 4.6vw, 70px) 22px; }
.rules-page { max-width: 820px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding-bottom: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: 0.07em; }
h1 { margin: 0; white-space: nowrap; font-size: clamp(38px, 4.3vw, 58px); font-weight: 850; letter-spacing: -0.055em; line-height: 1.05; }
h1 em { color: var(--blue); font-style: normal; }
.title-dot { color: var(--blue); }
.intro > p:last-child { max-width: 480px; margin: 0 0 2px; color: var(--muted); font-size: 14px; font-weight: 550; line-height: 1.6; }

.round-status {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  margin-bottom: 16px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.round-status > div { display: grid; gap: 1px; min-width: 0; padding: 8px 20px 9px 0; }
.round-status > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.round-status span { color: var(--muted); font-size: 12px; font-weight: 650; }
.round-status strong { font-size: 16px; font-weight: 800; letter-spacing: -0.025em; }
.mode-strip { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; margin: -6px 0 12px; background: #e9edfa; border-left: 3px solid var(--blue); font-size: 13px; }
.mode-strip strong { flex: none; color: #17327d; }
.mode-strip span { color: #344261; }
#countdown { color: var(--blue); font-variant-numeric: tabular-nums; }

.content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 320px); gap: 16px; align-items: start; }
.box { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ink); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading > div { display: flex; align-items: baseline; gap: 13px; }
.section-number { color: var(--blue); font-size: 12px; font-weight: 850; }
h2 { margin: 0; font-size: 18px; font-weight: 780; letter-spacing: -0.035em; line-height: 1.3; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.section-heading a { flex: none; font-size: 13px; font-weight: 700; }
.image-frame { position: relative; height: min(58dvh, 500px); min-height: 320px; overflow: hidden; background: #343b49; }
.image-frame img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.help { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.code-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; padding: 10px 13px; background: #e9edfa; border-left: 3px solid var(--blue); }
.code-strip code { color: #17327d; font-size: clamp(15px, 1.8vw, 21px); font-weight: 800; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.code-strip button { width: auto; min-height: 32px; margin: 0; padding: 3px 10px; white-space: nowrap; font-size: 12px; }
.qr-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel-label { display: block; padding: 5px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.qr-panels .image-frame { height: min(38dvh, 340px); min-height: 240px; background: #e8e7e2; }
.qr-panels .image-frame img { padding: 8px; image-rendering: pixelated; }
.qr-panels .image-frame img[hidden] { display: none; }
.preview-empty { display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; color: var(--muted); font-size: 12px; text-align: center; }
.preview-empty[hidden] { display: none; }
.target-panel { display: flex; gap: 12px; align-items: center; margin-top: 8px; padding: 5px 8px; background: #e8e7e2; }
.target-panel[hidden] { display: none; }
.target-panel img { width: 72px; height: 72px; object-fit: contain; }
.target-panel a { margin-left: auto; flex: none; font-size: 12px; font-weight: 700; }
.byte-view { margin-top: 13px; padding-top: 9px; border-top: 1px solid var(--line); }
.byte-view > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.byte-view pre { margin: 4px 0 0; max-height: 90px; overflow: auto; color: #344261; font: 11px/1.5 Consolas, ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.actions { display: grid; gap: 12px; }
.actions .section-heading { margin-bottom: 12px; }
.actions p:first-child { margin-top: 0; }
label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 700; }
input { display: block; width: 100%; min-height: 40px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #d5d5d2; border-radius: 0; outline: 0; }
input::placeholder { color: #85858c; }
input:focus { border-color: var(--blue); }
button { width: 100%; min-height: 40px; margin-top: 8px; padding: 7px 12px; color: #fff; background: var(--blue); border: 1px solid var(--blue); border-radius: 0; font-weight: 740; cursor: pointer; transition: background-color 150ms ease; }
button:hover { background: #1e42b5; }
button.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
button.secondary:hover { background: #ecebe7; }

.leaderboard-box { max-height: 230px; overflow: auto; }
.board-empty { padding: 10px 0 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.board-row { display: grid; grid-template-columns: 35px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); }
.board-row span { color: var(--blue); font-weight: 800; }
.board-row strong { overflow-wrap: anywhere; font-weight: 750; }
.board-row small { max-width: 140px; color: var(--muted); font-size: 13px; line-height: 1.35; text-align: right; }

#notice { position: fixed; right: 20px; bottom: 20px; display: none; max-width: min(400px, calc(100vw - 40px)); padding: 13px 17px; color: var(--ink); background: var(--surface); border: 1px solid var(--blue); border-top: 3px solid var(--blue); box-shadow: 0 8px 26px #0002; }
#notice.error { border-color: #b44343; }

@media (min-width: 901px) and (max-height: 800px) {
  .page { padding-top: 14px; padding-bottom: 14px; }
  .intro { padding-bottom: 10px; }
  .round-status { margin-bottom: 10px; }
  .qr-panels .image-frame { height: min(32dvh, 270px); min-height: 200px; }
  .actions { gap: 8px; }
  .actions .box { padding: 10px 14px; }
  .actions .section-heading { margin-bottom: 6px; }
  .actions input, .actions button { min-height: 36px; }
  .actions button { margin-top: 5px; }
  .actions .help { margin-top: 5px; }
}

@media (max-width: 900px) {
  .intro { align-items: start; flex-direction: column; gap: 9px; }
  .content { grid-template-columns: 1fr; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .leaderboard-box { grid-column: 1 / -1; }
  .image-frame { height: auto; min-height: 0; }
  .image-frame img { position: static; height: auto; }
  .qr-panels .image-frame img { height: 100%; }
}
@media (max-width: 640px) {
  .page { padding: 16px 12px 28px; }
  .intro { padding-bottom: 14px; }
  h1 { font-size: clamp(34px, 9vw, 48px); }
  .intro > p:last-child { font-size: 13px; }
  .mode-strip { display: block; }
  .mode-strip strong { display: block; }
  .round-status { grid-template-columns: 1.5fr 0.7fr 0.55fr; gap: 0; margin-bottom: 14px; }
  .round-status > div { padding-right: 8px; }
  .round-status > div + div { padding-left: 10px; }
  .round-status strong { font-size: 13px; }
  .actions { grid-template-columns: 1fr; gap: 12px; }
  .content { gap: 12px; }
  .box { padding: 13px; }
  .section-heading { margin-bottom: 10px; }
  h2 { font-size: 17px; }
  .qr-panels .image-frame { min-height: 160px; height: 30dvh; }
}
