@font-face {
  font-family: "Gaegu";
  src: url("./assets/fonts/Gaegu-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Gaegu";
  src: url("./assets/fonts/Gaegu-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #383b39;
  background: #fdfdfb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body { -webkit-font-smoothing: antialiased; }
body.is-home { overflow-y: auto; }
button:disabled { cursor: default; opacity: .45; }
.is-photo-library { background: #fdfdfb; }
.photo-library { width: min(1040px, calc(100% - 48px)); min-height: 100dvh; margin: auto; padding: 36px 0 64px; }
.photo-library-heading { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding-bottom: 28px; border-bottom: 1px solid #7e86733d; }
.photo-library-heading > a { justify-self: start; text-decoration: none; }
.photo-library-heading > button { justify-self: end; }
.photo-library h1, .photo-editor h2 { margin: 0; font: 700 34px/1.1 "Gaegu", cursive; color: #354b46; }
.photo-library-actions { display: flex; align-items: center; gap: 20px; margin: 28px 0 4px; }
#photo-library-count { font-size: 14px; color: #667166; }
.photo-status { min-height: 21px; margin: 10px 0; font: 14px/1.5 system-ui, sans-serif; color: #5b695d; }
.photo-status.is-error { color: #a04636; }
.photo-empty { display: grid; place-content: center; min-height: 320px; text-align: center; }
.photo-empty p { margin: 0 0 12px; font: 25px/1.3 "Gaegu", cursive; }
.photo-empty small { font-size: 14px; color: #788071; }
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 28px; margin-top: 16px; }
.photo-card { min-width: 0; padding: 0 0 16px; border-bottom: 1px solid #79807052; }
.photo-card-preview { display: grid; place-items: center; width: 100%; height: 190px; padding: 20px; border: 0; background: #f2f3ef; border-radius: 6px; }
.photo-card-preview:hover { background: #e9eee6; }
.photo-card-preview img { display: block; max-width: 100%; max-height: 150px; object-fit: contain; }
.photo-card h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 16px 0 5px; font: 700 24px/1.2 "Gaegu", cursive; }
.photo-card-detail { margin: 0 0 14px; font-size: 13px; color: #6b7369; }
.photo-card-footer { display: flex; gap: 10px; align-items: center; }
.photo-card-footer > label { margin-right: auto; font-size: 14px; }
.photo-card-footer select { min-height: 34px; margin-left: 7px; padding: 3px 8px; border: 1px solid #79807066; border-radius: 3px; background: transparent; font: inherit; }
.photo-card-footer .text-button { padding: 6px 3px; font-size: 19px; }
.photo-editor { width: min(1080px, calc(100vw - 40px)); max-height: calc(100dvh - 32px); padding: 24px 24px 0; overflow: hidden; border: 1px solid #808778; border-radius: 7px; background: #fdfdfb; color: #383b39; }
.photo-editor[open] { display: flex; flex-direction: column; }
.photo-editor::backdrop { background: #242c2b66; }
.photo-editor-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.photo-editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 26px; overflow: auto; min-height: 0; }
.photo-editor-heading { flex-shrink: 0; }
.photo-editor-footer { display: flex; justify-content: flex-end; flex-shrink: 0; padding: 12px 0 16px; border-top: 1px solid #7e867330; }
.photo-editor-footer #photo-save { width: 205px; margin: 0; }
.photo-workbench { min-width: 0; }
.photo-tools { display: flex; gap: 4px; flex-wrap: wrap; padding-bottom: 8px; }
.photo-tools button { min-height: 38px; padding: 6px 12px; color: #566252; border: 0; border-bottom: 2px solid transparent; background: transparent; font: 21px/1 "Gaegu", cursive; }
.photo-tools button[aria-pressed="true"] { color: #315c4c; border-bottom-color: #527b64; background: #edf1e8; }
.photo-tools button:hover:not(:disabled) { background: #edf1e8; }
.photo-tool-options { display: flex; gap: 20px; align-items: center; justify-content: space-between; min-height: 38px; margin-bottom: 10px; font-size: 13px; }
.photo-tool-options label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.photo-tool-options input[type="range"] { width: 96px; }
.photo-editor input[type="range"], .photo-editor input[type="checkbox"] { accent-color: #567c64; }
.photo-canvas-wrap { position: relative; width: 100%; height: clamp(270px, 46dvh, 470px); overflow: hidden; border: 1px solid #8890784a; border-radius: 4px; }
#photo-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.photo-view-controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; }
.photo-view-controls button { min-width: 36px; min-height: 36px; padding: 4px 9px; border: 1px solid #75826960; border-radius: 3px; color: #4b5c4a; background: #fdfdfbf2; font-size: 15px; }
.photo-cutout-actions { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.photo-cutout-actions .paper-button { font-size: 22px; min-height: 42px; padding: 7px 18px; }
#photo-loading { width: 100%; height: 6px; display: block; margin: 13px 0; accent-color: #567c64; }
.photo-form { min-width: 0; padding-left: 24px; border-left: 1px solid #7e867330; }
.photo-form > label, .photo-form details > label { display: grid; gap: 7px; margin-bottom: 17px; font-size: 14px; }
.photo-form input[type="text"], .photo-form input[type="number"], .photo-form select { width: 100%; min-width: 0; min-height: 38px; padding: 7px 9px; border: 1px solid #7a856357; border-radius: 3px; background: #fff; color: #3a413b; font: inherit; }
.photo-field-unit { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.photo-field-unit input { flex: 1; }
.photo-form summary { margin: 0 0 18px; font: 700 21px/1.2 "Gaegu", cursive; cursor: pointer; }
.photo-form .photo-auto-mass { display: flex; gap: 6px; align-items: center; font-size: 13px; margin-top: -9px; }
.photo-form .photo-auto-mass input { margin: 0; }
.photo-form input[type="range"] { width: 100%; min-width: 0; margin: 0; }
.photo-range-labels { display: flex; justify-content: space-between; font-size: 12px; color: #727969; margin: -13px 0 20px; }
#photo-save { width: 100%; margin-top: 2px; }
@media (max-width: 700px) {
  .photo-library { width: calc(100% - 32px); padding-top: 22px; }
  .photo-library-heading { grid-template-columns: 1fr auto; gap: 18px 10px; padding-bottom: 20px; }
  .photo-library-heading > a { grid-column: 1 / -1; }
  .photo-library-heading h1 { font-size: 30px; }
  .photo-library-heading > button { font-size: 22px; padding: 9px 14px; }
  .photo-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
  .photo-card-preview { height: 150px; padding: 12px; }
  .photo-card-preview img { max-height: 125px; }
  .photo-card-footer { flex-wrap: wrap; gap: 5px 10px; }
  .photo-card-footer > label { width: 100%; }
  .photo-editor { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 16px 16px 0; }
  .photo-editor-body { grid-template-columns: 1fr; gap: 18px; }
  .photo-editor-heading { margin-bottom: 12px; }
  .photo-editor h2 { font-size: 29px; }
  .photo-tools { gap: 0; }
  .photo-tools button { padding: 6px 9px; font-size: 20px; }
  .photo-tool-options { gap: 8px; font-size: 12px; }
  .photo-tool-options input[type="range"] { width: 75px; }
  .photo-canvas-wrap { height: 310px; }
  .photo-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 16px; padding: 18px 0 0; border: 0; border-top: 1px solid #7e867330; }
  .photo-form > label:first-child, .photo-form details, #photo-save { grid-column: 1 / -1; }
  .photo-form details { margin-top: 4px; }
  .photo-editor-footer #photo-save { width: 100%; }
}
button,
canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
a:focus-visible { outline: 2px solid #237b76b8; outline-offset: 4px; }

.home {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: clamp(40px, 7vw, 100px);
  width: min(1080px, calc(100% - 80px));
  min-height: 100dvh;
  margin: auto;
  padding: 48px 0 60px;
}
.home-intro { display: grid; justify-items: center; }
.home h1 {
  z-index: 1;
  margin: 0 0 -30px;
  color: #354b46;
  font: 700 clamp(64px, 6vw, 84px)/.76 "Gaegu", cursive;
  letter-spacing: -.025em;
  text-align: center;
  transform: rotate(-3deg);
}
.home h1 span { display: inline-block; margin: 7px 0 0 22px; }
.home-art { width: min(420px, 100%); aspect-ratio: 420 / 350; margin: 8px 0 22px; }
.paper-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 24px;
  border: 1.4px solid #5c635bc2;
  border-radius: 3px 6px 2px 5px / 5px 2px 5px 3px;
  background: #fdfdfb;
  color: #394d46;
  font: 700 23px/1.1 "Gaegu", cursive;
  text-decoration: none;
}
.start-button, .primary-button { background: #eaf0e9; border-color: #4f7466; }
.paper-button:hover { background: #e2ebe0; }
.start-button { min-width: 190px; transform: rotate(-1deg); }
.home-missions { align-self: center; min-width: 0; }
.home h2 { margin: 0 0 26px; font: 700 31px/1.2 "Gaegu", cursive; }
.place-tabs { display: flex; gap: 4px; border-bottom: 1px solid #777d7045; }
.place-tabs button {
  position: relative;
  flex: 1;
  padding: 12px 7px 15px;
  border: 0;
  background: none;
  color: #676e66;
  font: 23px/1 "Gaegu", cursive;
  white-space: nowrap;
}
.place-tabs button[aria-selected="true"] { color: #305c50; font-weight: 700; }
.place-tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 13%; right: 13%; bottom: 1px; height: 5px;
  background: url('./assets/ui/progress-fill.svg') left center / 170px 10px;
  transform: rotate(-1deg);
}
.mission-list { min-height: 268px; padding-top: 14px; }
.mission-link {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 14px;
  min-height: 122px;
  padding: 13px 12px 13px 0;
  border-bottom: 1px solid #7479702c;
  text-decoration: none;
}
.mission-link:hover { background: #eef1e863; }
.mission-art { display: block; width: 124px; height: 86px; }
.mission-copy { display: grid; gap: 7px; }
.mission-copy strong { font: 700 27px/1.1 "Gaegu", cursive; }
.mission-detail { font-size: 12px; color: #777b71; line-height: 1.5; }
.mission-arrow { font: 29px/1 "Gaegu", cursive; color: #576a5c; }
.mission-home { display: inline-grid; place-items: center; width: 36px; min-height: 40px; font: 28px/1 "Gaegu", cursive; text-decoration: none; }
.clear-dialog {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 36px);
  padding: 30px 28px 24px;
  border: 1.5px solid #545e52;
  border-radius: 4px 9px 3px 7px / 8px 3px 7px 4px;
  background: #fdfdfb;
  color: #383b39;
  text-align: center;
}
.clear-dialog::backdrop { background: #fdfdfb9e; backdrop-filter: blur(2px); }
.clear-mission { margin: 0; font: 20px/1.2 "Gaegu", cursive; color: #73786c; }
.clear-dialog h2 { margin: 14px 0 28px; color: #386b59; font: 700 48px/1 "Gaegu", cursive; }
.clear-records { display: flex; justify-content: center; gap: 34px; margin: 0 0 32px; }
.clear-records dt { font: 20px/1 "Gaegu", cursive; color: #6a7367; margin-bottom: 8px; }
.clear-records dd { margin: 0; font-size: 19px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.clear-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.clear-actions .result-button { white-space: nowrap; }
#clear-next::after { content: "→"; margin-left: .4em; }
.result-button { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 10px 14px; border: 1px solid #9ba896; border-radius: 6px; background: #fdfdfb; color: #435e4e; font: 700 23px/1.15 "Gaegu", cursive; text-decoration: none; cursor: pointer; }
.result-button:hover { background: #f0f3eb; border-color: #657b64; }
.result-primary { color: #2f5744; background: #e5edde; border-color: #829777; }
.result-primary:hover { background: #dbe7d2; }
.result-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.result-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 66px; padding: 8px 4px; border: 1px solid transparent; border-radius: 6px; background: #f3f5ee; color: #53664e; font: 20px/1.05 "Gaegu", cursive; cursor: pointer; }
.result-tool:hover { border-color: #a4b197; background: #eaf0e2; }
.result-tool svg, .ranking-board h3 svg { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.result-tool span { overflow-wrap: normal; word-break: keep-all; }
.result-button:focus-visible, .result-tool:focus-visible { outline: 2px solid #527b64; outline-offset: 3px; }
.text-button { min-height: 44px; margin-top: 14px; border: 0; background: transparent; color: #687363; font: 20px/1 "Gaegu", cursive; text-decoration: underline; text-underline-offset: 5px; }
@media (max-width: 700px) {
  .home { width: min(460px, calc(100% - 40px)); grid-template-columns: 1fr; gap: 40px; padding: 40px 0; }
  .home h1 { font-size: 60px; margin-bottom: -30px; }
  .home-art { width: 270px; margin-bottom: 12px; }
  .home h2 { font-size: 27px; margin-bottom: 13px; }
  .home-missions { padding-bottom: env(safe-area-inset-bottom); }
  .mission-list { min-height: 240px; }
  .mission-link { min-height: 112px; grid-template-columns: 110px minmax(0, 1fr) 20px; gap: 9px; }
  .mission-art { width: 106px; height: 76px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

/* The title, mission selection and settings are separate game screens. */
.home { display: block; width: min(1100px, calc(100% - 48px)); padding: 0; }
.title-screen { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 8%; min-height: 100dvh; padding: 40px 0; }
.home-intro { padding-bottom: 15px; }
.home-art { margin-bottom: 0; }
.main-menu { display: grid; justify-items: start; gap: 22px; padding-bottom: 12px; }
.menu-choice { position: relative; display: block; min-width: 180px; padding: 12px 10px; border: 0; background: none; color: #40463f; text-decoration: none; text-align: left; font: 700 34px/1.2 "Gaegu", cursive; }
.menu-label { position: relative; display: inline-block; padding-bottom: 7px; }
.menu-label::after { position: absolute; content: ""; left: 0; right: 0; bottom: 0; height: 6px; background: url('./assets/ui/progress-fill.svg') center / 100% 100% no-repeat; opacity: 0; pointer-events: none; }
.menu-choice:hover, .menu-choice:focus-visible { color: #326956; }
.menu-choice:not([aria-disabled='true']):hover .menu-label::after, .menu-choice:focus-visible .menu-label::after, #play-game .menu-label::after { opacity: .7; }
.home-missions { width: min(730px, 100%); margin: auto; padding: clamp(30px, 9vh, 90px) 0; }
.menu-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 40px; }
.menu-heading .text-button { margin: 0; text-decoration: none; color: #62695e; }
.menu-heading h2 { margin: 0; font: 700 34px/1.2 "Gaegu", cursive; }
.home-missions .menu-heading h2 { margin-right: auto; }
#choose-mission:focus { outline: none; }
.home-missions .mission-list { min-height: 0; }
.paper-button { border: 0; border-bottom: 2px solid #758b7960; border-radius: 0; background: transparent; }
.primary-button { color: #2e6552; border-bottom-color: #598571; }
.paper-button:hover { background: #e7edde80; }
.clear-dialog, .settings-dialog { border: 1px solid #7c84725c; border-radius: 8px; box-shadow: 0 12px 70px #404d4110; }
.settings-dialog { width: min(470px, calc(100% - 36px)); padding: 28px 30px; color: #424b40; background: #fdfdfb; }
.settings-dialog::backdrop { background: #fdfdfbba; backdrop-filter: blur(3px); }
.settings-dialog .menu-heading { margin-bottom: 25px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; min-height: 65px; border-top: 1px solid #77816c30; font: 23px/1.2 "Gaegu", cursive; }
.setting-row input { width: 22px; height: 22px; accent-color: #557968; cursor: pointer; }
.setting-hint { display: block; margin-top: 5px; color: #687361; font: 13px/1.4 "Gowun Dodum", sans-serif; }
.sound-volume { display: grid; grid-template-columns: clamp(80px, 20vw, 130px) 3rem; flex: 0 0 auto; align-items: center; gap: 10px; }
.sound-volume input[type="range"] { width: 100%; min-width: 0; margin: 0; }
.sound-volume output { min-width: 0; text-align: right; font-size: 18px; white-space: nowrap; }
.sound-volume:has(input:disabled) { opacity: .45; }
.setting-row select { min-height: 42px; padding: 5px 12px; border: 1px solid #87917e60; border-radius: 4px; background: transparent; color: inherit; font: inherit; }
@media (max-width: 650px) {
  .title-screen { grid-template-columns: 1fr; align-content: center; justify-items: center; gap: 20px; padding: 32px 0; }
  .home h1 { font-size: clamp(58px, 12vw, 72px); }
  .home-art { width: min(285px, 61vw); }
  .main-menu { justify-items: center; gap: 6px; padding: 0; }
  .menu-choice { font-size: 29px; min-width: 170px; text-align: center; padding-block: 11px; }
  .home-intro { padding: 0; }
  .menu-heading { margin-bottom: 28px; gap: 18px; }
  .menu-heading h2 { font-size: 29px; }
  .settings-dialog { padding: 24px; }
}
@media (max-height: 520px) and (min-width: 651px) {
  .title-screen { padding: 18px 0; }
  .home h1 { font-size: 60px; }
  .home-art { width: 260px; }
  .main-menu { gap: 10px; }
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.game-header {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: max(12px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 13px max(24px, env(safe-area-inset-left));
}

.game-header::after {
  position: absolute;
  right: 20px;
  bottom: 0;
  left: 20px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, #74736d50 4% 96%, transparent);
  pointer-events: none;
}

.mission-progress {
  display: grid;
  gap: 5px;
  width: clamp(180px, 17vw, 220px);
  min-width: 0;
}

.mission-progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mission-progress-heading strong {
  min-width: 42px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.stack-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  background: url('./assets/ui/progress-track.svg') center / 100% 100% no-repeat;
}

.stack-track > span {
  display: block;
  width: 100%;
  height: 100%;
  clip-path: inset(0 100% 0 0);
  background: url('./assets/ui/progress-fill.svg') left center / 100% 100% no-repeat;
}

.records {
  display: flex;
  justify-self: center;
  gap: clamp(24px, 4vw, 48px);
}

.record {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 2px 10px;
}

.record-label {
  font: 18px/1 "Gaegu", cursive;
  color: #555d55;
  white-space: nowrap;
}

.record strong {
  justify-self: end;
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.record small {
  grid-column: 1 / -1;
  justify-self: end;
  font-size: 10px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: #70776e;
  white-space: nowrap;
}

.mission-actions {
  grid-row: 1;
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

#mission-select {
  max-width: 112px;
  min-height: 38px;
  padding: 5px 3px;
  border: 0;
  background: transparent;
  color: #555d55;
  font: 18px/1 "Gaegu", cursive;
  cursor: pointer;
}

.reset-button {
  min-height: 40px;
  padding: 6px 13px;
  border: 1px solid #43454270;
  border-radius: 3px 5px 3px 4px;
  color: #3e423f;
  background: #fdfdfb;
  font: 19px/1 "Gaegu", cursive;
  white-space: nowrap;
}

.reset-button:hover,
.view-controls button:hover { background-color: #f3f4f2; }
.reset-button:active,
.view-controls button:active { background-color: #e9ece8; }

button:focus-visible,
select:focus-visible,
#game:focus-visible {
  outline: 2px solid #237b76b8;
  outline-offset: 3px;
}

.stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

#game.is-pan-ready { cursor: grab; }
#game.is-grabbing,
#game.is-panning { cursor: grabbing; }

.message {
  position: absolute;
  top: 12%;
  left: 50%;
  max-width: calc(100% - 32px);
  font: 700 27px/1.2 "Gaegu", cursive;
  color: #386f68;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
}

.start-hint {
  position: absolute;
  z-index: 2;
  top: clamp(18px, 5vh, 48px);
  left: 50%;
  width: min(340px, calc(100% - 40px));
  margin: 0;
  font: 700 clamp(20px, 2vw, 24px)/1.25 "Gaegu", cursive;
  color: #3f524a;
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
  transform: translateX(-50%) rotate(-0.25deg);
  text-shadow: 0 1px 0 #fff, 1px 0 0 #ffffffc7;
}

.start-hint[hidden],
.message[hidden] { display: none; }

.view-controls {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
}

.view-controls button {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 7px;
  border: 0;
  background: url('./assets/ui/control-frame.svg') center / 100% 100% no-repeat;
  color: #4d5750;
}

.view-controls button:nth-child(1) { transform: rotate(-0.2deg); }
.view-controls button:nth-child(2) {
  transform: rotate(0.18deg);
}
.view-controls button:nth-child(3) {
  transform: rotate(-0.12deg);
}

.view-controls svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

@media (max-width: 850px) {
  .game-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 16px;
    padding: max(10px, env(safe-area-inset-top)) 16px 12px;
  }

  .mission-progress {
    width: min(210px, 100%);
  }

  .records {
    justify-self: start;
    gap: 24px;
  }

  .record { gap: 2px 7px; }
  .record strong { font-size: 16px; }
  .reset-button {
    font-size: 17px;
    padding-inline: 10px;
  }
  .mission-actions { grid-column: 2; }
}

@media (max-width: 480px) {
  .game-header {
    gap: 10px 12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .records { gap: 14px; }
  .record { grid-template-columns: auto; gap: 3px; }
  .record strong,
  .record small { justify-self: start; }
  .mission-actions { display: grid; grid-template-columns: 44px minmax(70px, 96px); gap: 2px; align-items: center; }
  .mission-home { width: 44px; min-height: 44px; }
  .mission-actions .reset-button { grid-column: 1 / -1; min-height: 40px; }
  #mission-select { min-height: 44px; font-size: 17px; width: 100%; }

  .start-hint {
    width: min(290px, calc(100% - 28px));
    font-size: 20px;
  }
}

@media (max-height: 500px) and (min-width: 540px) {
  .game-header {
    gap: 18px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 6px;
  }

  .records { gap: 28px; }
  .record strong { font-size: 16px; }
  .reset-button { min-height: 36px; }
}

@media (pointer: coarse) {
  .view-controls button { width: 44px; height: 44px; }
}
.photo-local-note { display: block; color: #71776d; font-size: 12px; margin: 8px 0; }

/* Shared navigation and page rhythm. Game canvas remains full viewport. */
:root { --page-width: 1040px; --page-gutter: 24px; --page-top: 32px; }
.home, .photo-library { width: min(var(--page-width), calc(100% - 2 * var(--page-gutter))); margin: auto; }
.photo-library { padding: var(--page-top) 0 64px; }
.home-missions { width: 100%; margin: 0; padding: var(--page-top) 0 64px; }
.page-heading, .photo-library-heading { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 44px minmax(48px, auto); align-items: center; gap: 12px 24px; margin: 0 0 28px; padding: 0 0 22px; border-bottom: 1px solid #7e867330; }
.page-heading > .nav-back { grid-column: 1 / -1; justify-self: start; }
.page-heading h1 { grid-column: 1; margin: 0; text-align: left; letter-spacing: normal; transform: none; font: 700 34px/1.15 'Gaegu', cursive; color: #354b46; }
.page-heading > button { grid-column: 2; justify-self: end; }
.nav-back { display: inline-flex; align-items: center; gap: 9px; width: auto; min-height: 44px; margin: 0; padding: 6px 0; color: #526257; text-decoration: none; font: 21px/1.2 'Gaegu', cursive; white-space: nowrap; }
.nav-back svg, .icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-back:hover { color: #254c3e; }
.nav-back:focus-visible, .icon-button:focus-visible { outline: 2px solid #527b64; outline-offset: 3px; border-radius: 3px; }
.mission-groups { display: grid; gap: 32px; }
.mission-group h2 { margin: 0 0 10px; color: #5a685a; font: 700 24px/1.2 'Gaegu', cursive; }
.mission-group .mission-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 36px; }
.mission-group .mission-link { position: relative; display: grid; grid-template-columns: 112px 1fr auto; align-items: center; min-width: 0; min-height: 106px; gap: 16px; padding: 8px 4px; border-bottom: 1px solid #7e867330; }
.mission-group .mission-art { width: 112px; height: 78px; }
.mission-copy { min-width: 0; }
.mission-group .mission-copy strong { font-size: 27px; }
.mission-group .mission-detail { margin-top: 7px; font: 12px/1.4 system-ui, sans-serif; color: #708073; }
.clear-stamp { display: grid; place-items: center; width: 45px; height: 45px; border: 2px solid #658b76; border-radius: 50%; outline: 1px solid #658b7655; outline-offset: -5px; color: #557863; font: 700 18px/1 'Gaegu', cursive; transform: rotate(-12deg); opacity: .86; }
.photo-library-actions { margin-top: 0; }
.photo-card-footer input[type='number'] { width: 65px; min-height: 38px; margin-left: 7px; padding: 5px 6px; border: 1px solid #79807066; border-radius: 3px; background: transparent; color: inherit; font: inherit; }
.photo-card-footer .text-button, .photo-cutout-actions .text-button, .photo-editor-heading .text-button { margin-top: 0; }
.builtin-card > .builtin-preview { display: grid; place-items: center; width: 100%; height: 190px; padding: 20px; border-radius: 6px; background: #f2f3ef; }
.builtin-preview img { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 150px; object-fit: contain; }
.builtin-wood-block { width: 64px; height: 40px; border: 1px solid #80694e80; border-radius: 2px; background: url('./assets/previews/wood-pencil.webp') center / cover; box-shadow: inset 0 0 0 1px #fff4; }
.builtin-picker { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px 24px 24px; overflow: hidden; border: 1px solid #7c84725c; border-radius: 8px; box-shadow: 0 12px 70px #404d4110; background: #fdfdfb; color: #424b40; }
.builtin-picker::backdrop { background: #fdfdfbba; backdrop-filter: blur(3px); }
.builtin-picker[open] { display: flex; flex-direction: column; }
.builtin-picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex: none; padding-bottom: 14px; border-bottom: 1px solid #7e867330; }
.builtin-picker-heading h2 { margin: 0; font: 700 32px/1.1 'Gaegu', cursive; color: #354b46; }
.builtin-picker-heading .text-button { margin: 0; text-decoration: none; }
.builtin-picker-list { min-height: 0; overflow: auto; padding: 8px 2px 4px; }
.builtin-picker-group { padding: 16px 0 8px; }
.builtin-picker-group + .builtin-picker-group { border-top: 1px solid #7e867330; }
.builtin-picker-group h3 { margin: 0 0 10px; font: 700 23px/1.1 'Gaegu', cursive; color: #53685c; }
.builtin-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.builtin-picker-card { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 90px minmax(2.2em, auto) 44px; align-items: center; gap: 6px; min-width: 0; padding: 8px; border: 1px solid #7d887428; border-radius: 5px; background: #fafbf8; }
.builtin-picker-card:hover { background: #f1f4ed; }
.builtin-picker-card .builtin-preview { grid-column: 1 / -1; display: grid; place-items: center; height: 90px; min-width: 0; }
.builtin-picker-card .builtin-preview img { max-height: 82px; }
.builtin-picker-title { min-width: 0; font: 18px/1.1 'Gaegu', cursive; overflow-wrap: anywhere; text-wrap: balance; }
.builtin-picker-card input[type='number'] { justify-self: end; width: 44px; min-height: 44px; padding: 3px; border: 1px solid #79807066; border-radius: 3px; background: transparent; color: inherit; font: inherit; text-align: center; }
.builtin-pallet { position: relative; width: min(145px, 100%); aspect-ratio: 1.65 / .23; }
.builtin-pallet span { position: absolute; display: block; border: 1px solid #80694e80; border-radius: 2px; background: url('./assets/previews/wood-pencil.webp') center / cover; box-shadow: inset 0 0 0 1px #fff4; }
.builtin-pallet span:nth-child(1) { inset: 0 0 auto; height: 33%; }
.builtin-pallet span:nth-child(2) { left: 4%; bottom: 0; width: 92%; height: 20%; }
.builtin-pallet span:nth-child(n + 3) { top: 33%; width: 16%; height: 43%; transform: translateX(-50%); }
.builtin-pallet span:nth-child(3) { left: 16%; }
.builtin-pallet span:nth-child(4) { left: 50%; }
.builtin-pallet span:nth-child(5) { left: 84%; }
.photo-tools { align-items: center; }
.edit-history { display: inline-flex; margin-left: auto; gap: 2px; }
.photo-tools .icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 7px; border: 0; border-radius: 3px; }
#photo-brush-preview { position: absolute; left: 0; top: 0; pointer-events: none; border: 1px solid #fff; box-shadow: 0 0 0 1px #273c32, inset 0 0 0 1px #273c324d; border-radius: 50%; transform: translate(-50%, -50%); z-index: 2; }
#photo-brush-preview[data-tool='restore'] { background: #53865b18; }
#photo-canvas[data-brush='true'] { cursor: none; }
#photo-canvas[data-tool='pan'] { cursor: grab; }
.mission-actions .nav-back { padding: 6px; font-size: 20px; }
.is-custom-game .records { justify-self: center; }
@media (max-width: 700px) {
  :root { --page-gutter: 16px; --page-top: 20px; }
  .photo-library { width: calc(100% - 2 * var(--page-gutter)); padding-top: var(--page-top); }
  .page-heading, .photo-library-heading { grid-template-columns: 1fr auto; gap: 10px 12px; margin-bottom: 24px; padding-bottom: 18px; }
  .page-heading h1 { font-size: 30px; }
  .mission-group .mission-list { gap: 0 18px; }
  .mission-group .mission-link { grid-template-columns: 76px 1fr; gap: 8px; min-height: 98px; }
  .mission-group .mission-art { width: 76px; height: 66px; }
  .mission-group .mission-copy strong { font-size: 24px; }
  .clear-stamp { position: absolute; top: 1px; left: 48px; width: 34px; height: 34px; font-size: 14px; background: #fdfdfbd9; }
  .mission-group .mission-detail { font-size: 11px; }
  .photo-tools button { padding: 6px 8px; font-size: 20px; }
  .photo-tools .icon-button { width: 36px; height: 38px; padding: 6px; }
  .builtin-card > .builtin-preview { height: 150px; padding: 12px; }
  .builtin-preview img { max-height: 125px; }
  .builtin-picker { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 16px; }
  .builtin-picker-heading h2 { font-size: 29px; }
  .builtin-picker-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .builtin-picker-card { grid-template-rows: 76px minmax(2.2em, auto) 44px; padding: 6px; }
  .builtin-picker-card .builtin-preview { height: 76px; }
  .builtin-picker-card .builtin-preview img { max-height: 70px; }
  .builtin-picker-title { font-size: 17px; }
}
@media (max-width: 390px) {
  .photo-library-actions { flex-wrap: wrap; gap: 8px 14px; }
  .builtin-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builtin-picker { padding: 14px; }
  .builtin-picker-heading { gap: 10px; }
}
@media (max-width: 480px) {
  .mission-group .mission-list { grid-template-columns: 1fr; }
  .mission-group .mission-link { grid-template-columns: 104px 1fr auto; min-height: 96px; gap: 16px; }
  .mission-group .mission-art { width: 104px; height: 72px; }
  .clear-stamp { position: static; width: 40px; height: 40px; font-size: 17px; }
  .mission-actions { grid-template-columns: auto; justify-items: end; }
  .mission-actions .nav-back { min-height: 36px; font-size: 18px; padding: 0; }
  .mission-actions .nav-back svg { width: 18px; height: 18px; }
  #mission-select { display: none; }
  .mission-actions .reset-button { grid-column: auto; }
  .edit-history { margin-left: 0; }
}
.photo-toolbar { position: sticky; top: 0; z-index: 3; background: #fdfdfb; padding-bottom: 1px; }
@media (max-height: 500px) and (min-width: 540px) {
  .photo-toolbar { position: static; }
  .photo-canvas-wrap { height: clamp(140px, 40dvh, 200px); }
}
/* Preserve the original navigation → progress → records → controls sequence. */
.game-header {
  width: min(1120px, calc(100% - 2 * var(--page-gutter)));
  margin: 0 auto;
  padding: 16px 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "back stats actions";
  align-items: center;
  gap: 24px;
}
.game-header::after { left: 0; right: 0; }
.game-header > .nav-back { grid-area: back; justify-self: start; min-width: 0; white-space: nowrap; font-size: 20px; }
.game-header > .nav-back svg { flex: none; }
.game-stats { grid-area: stats; display: flex; align-items: center; justify-content: center; gap: 24px; min-width: 0; }
.game-header .mission-progress { flex: 0 1 180px; width: 180px; min-width: 180px; gap: 5px; }
.game-header .mission-progress-heading { gap: 8px; flex-wrap: nowrap; align-items: baseline; }
.game-header .mission-progress-heading .record-label { white-space: nowrap; }
.game-header .mission-progress-heading strong { margin: 0; min-width: 32px; font-size: 16px; }
.game-header .stack-track { height: 10px; }
.game-header .records { display: flex; justify-content: center; gap: 20px; min-width: 0; flex: none; }
.game-header .record { min-width: 0; grid-template-columns: auto auto; gap: 3px 8px; }
.game-header .record-label { font-size: 17px; line-height: 1.2; }
.game-header .record strong { font-size: 17px; line-height: 1.3; justify-self: end; }
.game-header .record small { font-size: 10px; line-height: 1.2; justify-self: end; }
.game-header .mission-actions { grid-area: actions; display: flex; align-items: center; gap: 12px; max-width: none; }
.game-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.game-header .hud-icon { width: 34px; height: 40px; min-width: 34px; }
.game-header .hud-icon svg { width: 23px; height: 23px; }
.mission-navigation { display: flex; align-items: center; gap: 8px; min-width: 0; }
.game-header #mission-select { display: block; flex: none; width: auto; min-width: 0; max-width: none; min-height: 40px; padding: 5px 4px; font-size: 18px; }
.game-header .reset-button { flex: none; min-height: 40px; margin: 0; padding: 6px 12px; font-size: 18px; }
.game-header:has(#mission-select[hidden]) { grid-template-areas: "back stats actions"; }
.game-header:has(#mission-select[hidden]) .game-stats { flex-wrap: nowrap; }
@media (max-width: 1140px) and (min-width: 1001px) {
  .game-header { column-gap: 16px; }
  .game-stats { gap: 18px; }
  .game-header .record { grid-template-columns: 1fr; gap: 2px; }
  .game-header .record strong, .game-header .record small { justify-self: start; }
  .game-header .records { gap: 18px; }
  .game-header .mission-progress { flex-basis: 160px; width: 160px; min-width: 160px; grid-template-rows: 20px 22px 12px; gap: 2px; }
  .game-header .mission-progress-heading { display: contents; }
  .game-header .mission-progress-heading .record-label { grid-area: 1 / 1; }
  .game-header .mission-progress-heading strong { grid-area: 2 / 1; justify-self: start; font-size: 17px; line-height: 22px; }
  .game-header .stack-track { grid-area: 3 / 1; align-self: center; }
  .game-header .record { grid-template-rows: 20px 22px 12px; }
  .game-header .record-label { line-height: 20px; }
  .game-header .record strong { line-height: 22px; }

}
@media (max-width: 1000px) {
  .game-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "back actions" "stats stats"; gap: 10px 18px; padding: 10px 0; }
  .game-stats { justify-content: center; gap: 24px; }
  .game-header .mission-progress { flex: 0 1 180px; width: 180px; }
  .game-header .record { grid-template-columns: auto auto; gap: 3px 8px; }
  .game-header .record strong, .game-header .record small { justify-self: end; }
  .game-header:has(#mission-select[hidden]) { grid-template-areas: "back actions" "stats stats"; }
}
@media (max-width: 600px) {
  .game-header { grid-template-areas: "back tools" "navigation navigation" "stats stats"; gap: 6px 12px; padding: 8px 0 12px; }
  .game-header .mission-actions { display: contents; }
  .game-tools { grid-area: tools; justify-self: end; }
  .game-header .hud-icon { width: 38px; min-width: 38px; height: 44px; }
  .mission-navigation { grid-area: navigation; justify-content: space-between; }
  .game-header #mission-select { min-height: 40px; padding-left: 0; }
  .game-header .reset-button { min-height: 40px; }
  .game-header > .nav-back { font-size: 18px; }
  .game-stats { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding-top: 6px; }
  .game-header .mission-progress { grid-area: 1 / 1; grid-template-columns: 1fr; width: auto; min-width: 0; grid-template-rows: 19px 21px 12px; row-gap: 2px; }
  .game-header .mission-progress-heading { display: contents; }
  .game-header .mission-progress-heading .record-label { grid-area: 1 / 1; }
  .game-header .mission-progress-heading strong { grid-area: 2 / 1; justify-self: start; font-size: 16px; line-height: 21px; }
  .game-header .stack-track { grid-area: 3 / 1; align-self: center; }
  .game-header .records { grid-area: 1 / 2; gap: 20px; }
  .game-header .record { grid-template-columns: auto; grid-template-rows: 19px 21px 12px; gap: 2px; }
  .game-header .record strong, .game-header .record small { justify-self: start; }
  .game-header .record strong { font-size: 16px; line-height: 21px; }
  .game-header .record-label { font-size: 17px; line-height: 19px; }
  .game-header .record small { font-size: 10px; line-height: 12px; }
  .game-header:has(#mission-select[hidden]) { display: flex; flex-wrap: wrap; gap: 6px 10px; }
  .game-header:has(#mission-select[hidden]) > .nav-back { order: 0; flex: 1 1 calc(100% - 128px); }
  .game-header:has(#mission-select[hidden]) .game-tools { order: 1; flex: 0 0 118px; }
  .game-header:has(#mission-select[hidden]) .game-stats { order: 2; display: flex; justify-content: start; flex: 1 1 0; }
  .game-header:has(#mission-select[hidden]) .mission-navigation { order: 3; flex: none; }
}
@media (max-width: 380px) {
  .game-stats, .game-header .records { gap: 12px; }
  .game-header .record-label, .game-header .mission-progress-heading .record-label { font-size: 16px; }
  .game-header .record strong, .game-header .mission-progress-heading strong { font-size: 14px; }
}
@media (max-height: 500px) and (min-width: 620px) and (max-width: 1000px) {
  .game-header { grid-template-areas: "back actions" "stats stats"; gap: 4px 12px; padding-block: 6px; }
  .game-header .mission-actions { display: flex; gap: 8px; }
  .game-header .mission-progress-heading { display: flex; }
  .game-header .mission-progress { display: grid; grid-template-rows: auto auto; min-width: 160px; }
  .game-header .mission-progress-heading strong { font-size: 16px; }
  .game-header .stack-track { grid-row: auto; }
  .game-stats { display: flex; padding: 0; justify-content: center; gap: 24px; }
  .game-header .record { grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 2px 8px; }
  .game-header .record strong, .game-header .record small { justify-self: end; }
  .game-header .hud-icon { min-width: 34px; width: 34px; height: 40px; }
  .game-header:has(#mission-select[hidden]) { grid-template-areas: "back actions" "stats stats"; }
}

@media (max-width: 380px) {
  .clear-dialog { padding-inline: 20px; }
  .clear-records { gap: 18px; }
  .clear-actions { gap: 8px; }
  .result-button { padding-inline: 8px; font-size: 21px; }
  .result-tool { font-size: 18px; }
}

/* Endless keeps the same paper controls; height records replace the mission goal. */
:lang(ko) #game-title { white-space: nowrap; letter-spacing: -.04em; }
#game-title { max-width: 100%; }
#setting-language { min-width: 126px; }
.setting-row > span { word-break: keep-all; }
.start-hint { word-break: keep-all; }
.main-menu { gap: 16px; }
.is-endless-game .record-label { white-space: nowrap; }
.stone-supply { position: absolute; bottom: 18px; left: 24px; display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 14px; color: #4d5c51; background: #fdfdfbf2; padding: 7px 12px; border-radius: 3px; }
.stone-supply button { font-size: 23px; min-height: 42px; }
.stone-supply button:disabled { color: #82867d; border-color: #8b938a45; cursor: default; }
.stone-supply span { font: 20px/1.2 'Gaegu', cursive; }
.stone-supply small { grid-column: 1 / -1; font: 13px/1.4 system-ui,sans-serif; }
:lang(en) .game-header .nav-back { font-size: 20px; }
:lang(en) .setting-row { font-size: 21px; }
@media (max-width: 720px) {
  .stone-supply { left: 12px; bottom: 65px; max-width: calc(100% - 24px); gap: 3px 12px; padding: 5px 9px; }
  .stone-supply button { font-size: 21px; }
  .main-menu { gap: 4px; }
  :lang(en) .game-header .record-label { font-size: 16px; }
  :lang(en) .game-header .nav-back { font-size: 18px; }
}

:lang(en) .clear-stamp { font-size: 13px; letter-spacing: -.3px; }

/* Shared mission tools keep the same pencil stroke and hit area as view tools. */
.hud-icon { width: 38px; height: 38px; min-width: 38px; color: #53665b; border: 0; background: transparent; border-radius: 50%; }
.hud-icon:hover { background: #e9eee7; }
.hud-icon svg { width: 25px; height: 25px; stroke-width: 1.5; }
.mode-lock { display: block; font: 15px/1.5 'Gaegu', cursive; color: #7c8076; }
.menu-choice[aria-disabled='true'] { color: #8b8f85; cursor: default; }
.game-loading { position: absolute; inset: 0; display: flex; gap: 12px; justify-content: center; align-items: center; background: #fdfdfb; color: #59675e; font: 22px 'Gaegu', cursive; z-index: 4; }
.game-loading[hidden] { display: none; }
.pencil-spinner { width: 27px; height: 27px; border: 2px solid #8c9b8460; border-top-color: #5b7666; border-radius: 48% 52% 46% 54%; animation: pencil-turn 1s linear infinite; }
@keyframes pencil-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pencil-spinner { animation-duration: 3s; } }
.community-dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 26px; border: 1px solid #7c84725c; border-radius: 8px; background: #fdfdfb; color: #424b40; box-shadow: 0 12px 70px #404d4110; }
.community-dialog::backdrop { background: #fdfdfbba; backdrop-filter: blur(3px); }
.community-dialog .menu-heading { margin-bottom: 18px; }
.community-dialog h2 { font: 700 30px 'Gaegu', cursive; margin: 0; }
.share-dialog { width: min(510px, calc(100% - 32px)); }
#share-preview { display: block; width: 100%; height: min(50dvh, 510px); object-fit: contain; margin: 0 auto 18px; }
.share-actions { display: flex; justify-content: center; gap: 14px; }
#share-link { width: 100%; margin-top: 12px; }
.community-status { min-height: 1.4em; font-size: 14px; line-height: 1.5; margin-bottom: 0; }
.ranking-dialog { width: min(840px, calc(100% - 32px)); }
.ranking-filters { margin-bottom: 24px; }
.ranking-filters select { width: min(270px, 100%); min-height: 44px; font: 22px/1.2 'Gaegu', cursive; }
.ranking-boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.ranking-boards.single-board { grid-template-columns: minmax(0, 1fr); max-width: 480px; margin-inline: auto; }
.ranking-board { min-width: 0; }
.ranking-board h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: #42624e; font: 700 25px/1.2 'Gaegu', cursive; }
.ranking-board + .ranking-board { border-left: 1px solid #b1baa34d; padding-left: 28px; }
.single-board .ranking-board { border: 0; padding: 0; }
#ranking-form { display: flex; align-items: flex-end; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #b1baa34d; }
#ranking-form label { min-width: 0; flex: 1; font: 20px 'Gaegu', cursive; }
#ranking-name { display: block; width: 100%; min-height: 44px; margin-top: 6px; font: 16px sans-serif; }
#ranking-form button { white-space: nowrap; min-height: 44px; font-size: 21px; }
.community-dialog input, .community-dialog select { padding: 8px 10px; border: 1px solid #a8b1a3; border-radius: 5px; background: transparent; color: inherit; }
.ranking-table-wrap { max-height: 36dvh; overflow: auto; scrollbar-width: thin; }
.ranking-table-wrap:focus-visible { outline: 2px solid #527b64; outline-offset: 3px; }
.ranking-table-wrap table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.ranking-table-wrap th { position: sticky; top: 0; background: #fdfdfb; font-weight: 500; color: #657466; text-align: left; }
.ranking-table-wrap td, .ranking-table-wrap th { padding: 11px 6px; border-bottom: 1px solid #b1baa338; vertical-align: middle; }
.ranking-table-wrap th:first-child { width: 42px; }
.ranking-table-wrap td:nth-child(2) { overflow-wrap: anywhere; }
.ranking-table-wrap td:last-child, .ranking-table-wrap th:last-child { width: 112px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking-own { padding: 10px 8px; margin: 12px 0 0; background: #e9efe680; font-size: 13px; line-height: 1.5; }
.ranking-board .community-status { margin-top: 12px; }
.ranking-dialog .community-status:empty { display: none; }
.ranking-board .text-button { margin-top: 4px; }
@media (max-width: 620px) {
  #clear-next::after { display: none; }
  .clear-actions .result-button { padding-inline: 8px; font-size: 20px; }
  :lang(en) .clear-actions .result-button { font-size: 18px; }
  .ranking-boards { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .ranking-board + .ranking-board { border-left: 0; padding-left: 0; border-top: 1px solid #b1baa34d; padding-top: 20px; }
  .single-board .ranking-board { border: 0; padding: 0; }
  .ranking-table-wrap { max-height: min(22dvh, 180px); }
  .single-board .ranking-table-wrap { max-height: 42dvh; }
  .ranking-filters { margin-bottom: 20px; }
  .ranking-board h3 { font-size: 24px; margin-bottom: 8px; }
  #ranking-form { margin-top: 20px; padding-top: 16px; }
}
.own-record { background: #e9efe680; }
.shared-tower { width: min(var(--page-width), calc(100% - 2 * var(--page-gutter))); margin: 28px auto; text-align: center; }
#shared-image { display: block; max-width: 100%; max-height: 75dvh; object-fit: contain; margin: 24px auto; }
@media (max-width: 760px) { .community-dialog { padding: 20px; } }

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

@media (max-width: 380px) {
  .game-header > .nav-back { min-width: 0; max-width: 100%; white-space: normal; font-size: 18px; }
  .game-header > .nav-back svg { flex: none; }
  .ranking-dialog { padding: 16px; }
  .ranking-table-wrap { max-height: 20dvh; }
  .ranking-table-wrap table { font-size: 13px; }
  .ranking-table-wrap td, .ranking-table-wrap th { padding: 9px 4px; }
  .ranking-table-wrap th:first-child { width: 32px; }
  .ranking-table-wrap td:last-child, .ranking-table-wrap th:last-child { width: 96px; }
  #ranking-form { gap: 8px; }
  #ranking-form button { padding-inline: 8px; font-size: 18px; }
}

/* Secondary legal links sit below the game choices without competing with them. */
.privacy-link { color: #697567; font: 13px/1.5 system-ui, sans-serif; text-underline-offset: 4px; }
.privacy-link:hover { color: #326956; }
.privacy-link:focus-visible { outline: 2px solid #557968; outline-offset: 4px; }
.menu-privacy { padding: 12px 10px; margin-top: 4px; }
.settings-footer { border-top: 1px solid #77816c30; padding-top: 18px; text-align: right; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-delete { border: 0; background: none; padding: 10px 0; color: #866053; font: 13px/1.5 system-ui, sans-serif; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.settings-delete:focus-visible { outline: 2px solid #866053; outline-offset: 4px; }
.settings-records-status { margin: 12px 0 0; font: 14px/1.5 system-ui, sans-serif; color: #52624d; }
.settings-records-status:empty { display: none; }
.delete-records-dialog h2 { margin: 0 0 24px; font: 700 32px/1.2 'Gaegu', cursive; }
.delete-records-dialog p { line-height: 1.65; word-break: keep-all; }
.delete-records-detail { color: #677060; font-size: 14px; }
.delete-records-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
#confirm-delete-records { color: #895b4d; border-color: #ab8b795e; }
