:root {
  color-scheme: dark;
  font-family:
    system-ui,
    -apple-system,
    "Malgun Gothic",
    sans-serif;
  color: #d9d0b8;
  background: #141b18;
  font-size: 13px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 0, #293629 0, #141b18 65%);
  min-height: 100vh;
}
body.booting .masthead,
body.booting .connection-line,
body.booting .side-panel,
body.booting .action-bar,
body.booting .mobile-controls,
body.booting .mobile-toolbar,
body.booting .chat-form,
body.booting .footnote {
  visibility: hidden;
}
body.booting .game-layout {
  display: block;
}
body.booting .play-column {
  max-width: 640px;
  margin: auto;
}
body.booting #stage {
  background: #000 url("assets/ui/logo.png?v=v3-3bf6d39") center / contain no-repeat;
}
button,
input,
select {
  font: inherit;
}
button {
  color: #ead8ad;
  background: linear-gradient(#65452a, #402c1d);
  border: 1px solid #977346;
  border-radius: 3px;
  padding: 9px 10px;
  cursor: pointer;
}
button:hover {
  background: linear-gradient(#80603b, #513922);
  border-color: #d2b780;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid #6cd0d6;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
a {
  color: inherit;
  text-decoration: none;
}
input {
  min-width: 0;
  color: #ece5d1;
  background: #171e1a;
  border: 1px solid #615a43;
  border-radius: 3px;
  padding: 9px;
}
input::placeholder {
  color: #8c9488;
}
.masthead {
  max-width: 1040px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 94px;
  padding: 0 24px;
  border-bottom: 1px solid #4b513d;
}
.portal-link {
  font-size: 12px;
  color: #9ea993;
}
.wordmark {
  text-align: center;
}
.wordmark span {
  display: block;
  font-family: Georgia, serif;
  letter-spacing: 0.14em;
  font-size: 29px;
  color: #d6b47b;
  text-shadow: 0 2px #000;
}
.wordmark small {
  display: block;
  letter-spacing: 0.32em;
  font-size: 10px;
  margin-top: 3px;
  color: #8e9b87;
}
.quiet {
  background: transparent;
  border-color: #4c5745;
  color: #a9b29e;
}
main {
  max-width: 1040px;
  margin: auto;
  padding: 21px 24px 35px;
}
.connection-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #a4ae96;
}
#network-status::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #7cae77;
  border-radius: 50%;
  margin-right: 7px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(220px, 264px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}
.play-column {
  min-width: 0;
}
.stage {
  position: relative;
  aspect-ratio: 4/3;
  width: 100%;
  box-shadow: 0 15px 45px #0008;
  touch-action: none;
  overflow: hidden;
  background: #000;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  outline-offset: -3px;
  touch-action: none;
}
.stage-notice {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 43%;
  text-align: center;
  color: #e1c989;
  text-shadow: 0 2px #000;
  background: #152019df;
  padding: 18px;
  border: 1px solid #82704b;
}
.stage-notice[hidden] {
  display: none;
}
.chat-log {
  position: absolute;
  left: 10%;
  top: 87%;
  width: 61%;
  height: 9%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff5d7;
  font-size: clamp(8px, 1.15vw, 11px);
  line-height: 1.35;
  text-shadow: 1px 1px #000;
  pointer-events: none;
}
.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}
.chat-form label {
  font-size: 11px;
  color: #b89865;
}
.chat-form input {
  flex: 1;
  padding: 8px;
  font-size: 12px;
}
.chat-form button {
  padding: 8px 13px;
}
.action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 9px;
}
.action-bar button {
  padding: 10px 4px;
  font-size: 12px;
}
kbd {
  font-size: 9px;
  opacity: 0.5;
  margin-left: 4px;
}
.side-panel {
  min-width: 0;
  border: 1px solid #5e5b3f;
  background: #1c241ede;
  box-shadow: 0 14px 40px #0003;
}
.commander-card {
  padding: 18px;
}
.eyebrow {
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #af9664;
}
h1 {
  font-size: 20px;
  font-weight: 500;
  margin: 7px 0 4px;
  color: #eee0bc;
}
#player-class {
  font-size: 11px;
  color: #a3ae93;
  margin-bottom: 13px;
}
.meter {
  position: relative;
  background: #0e130f;
  border: 1px solid #534d36;
  border-radius: 2px;
  height: 18px;
  margin: 6px 0;
  overflow: hidden;
}
.meter i {
  display: block;
  width: 0;
  height: 100%;
  transition: width 0.2s;
}
.meter.hp i {
  background: linear-gradient(90deg, #783f32, #b96743);
}
.meter.mp i {
  background: linear-gradient(90deg, #30465f, #527da1);
}
.meter span {
  position: absolute;
  inset: 0;
  text-align: center;
  font: 10px/16px system-ui;
  color: #f6ead0;
  text-shadow: 1px 1px #000;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 11px;
  font-size: 11px;
  margin-top: 10px;
  color: #aeb79e;
}
.target-label {
  min-height: 32px;
  border-top: 1px solid #424932;
  padding-top: 10px;
  margin-top: 12px;
  font-size: 11px;
  color: #c5b581;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-top: 1px solid #5e5b3f;
  border-bottom: 1px solid #5e5b3f;
}
.tabs button {
  border: 0;
  border-right: 1px solid #4b4b33;
  border-radius: 0;
  background: #232d22;
  padding: 11px 1px;
  font-size: 11px;
  color: #8e9e87;
}
.tabs button[aria-selected="true"] {
  background: #41452d;
  color: #e6ce91;
}
.tab-panel {
  padding: 12px;
}
.tab-panel input {
  width: 100%;
  padding: 8px;
  margin: 5px 0 8px;
  font-size: 11px;
}
.field-label,
.panel-caption {
  font-size: 10px;
  color: #9da78b;
}
.panel-caption {
  padding: 3px 0 8px;
}
.scroll-list {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-color: #616443 #1b221b;
}
.scroll-list.short {
  max-height: 150px;
}
.row {
  display: flex;
  width: 100%;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #37402e;
  border-radius: 0;
  padding: 9px 3px;
  font-size: 11px;
  color: #bfc5a9;
}
.row.active {
  color: #ebd39c;
  background: #363e2c;
}
.row small {
  display: block;
  color: #808f76;
  font-size: 9px;
  margin-top: 3px;
}
.row img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}
.row .description {
  flex: 1;
}
.row .badge {
  font-size: 9px;
  white-space: nowrap;
  color: #a39163;
}
.row-action {
  padding: 5px 7px;
  font-size: 10px;
}
.button-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 9px 0;
}
.button-row button {
  font-size: 10px;
  padding: 7px 8px;
}
.dialogue {
  white-space: pre-wrap;
  max-height: 250px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.7;
  color: #d4cdb1;
}
.leave {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  background: transparent;
  border-color: #5a6145;
  font-size: 11px;
  color: #a9b79b;
}
.footnote {
  text-align: center;
  font-size: 10px;
  color: #7e8e77;
  margin-top: 18px;
  line-height: 1.8;
}
.text-button {
  background: none;
  border: 0;
  color: #b3a16c;
  padding: 0 5px;
  font-size: 10px;
}
.mobile-controls {
  display: none;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(2, 36px);
  gap: 3px;
}
.dpad button {
  padding: 0;
  touch-action: none;
  user-select: none;
}
.dpad [data-dir="up"] {
  grid-column: 2;
}
.dpad [data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}
.dpad [data-dir="down"] {
  grid-column: 2;
  grid-row: 2;
}
.dpad [data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}
dialog {
  max-width: 490px;
  width: calc(100% - 28px);
  color: #d7d3b9;
  background: linear-gradient(145deg, #293425, #18221b);
  border: 1px solid #9b8559;
  border-radius: 5px;
  padding: 30px;
  box-shadow: 0 20px 100px #000b;
}
dialog::backdrop {
  background: #0a130ee0;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font-family: Georgia, "Malgun Gothic", serif;
  color: #e2c78a;
  font-size: 25px;
  font-weight: 500;
}
dialog p {
  font-size: 12px;
  line-height: 1.9;
  color: #adb89e;
}
dialog label {
  display: block;
  font-size: 12px;
  margin-bottom: 7px;
}
dialog #name-input {
  width: 100%;
  margin: 0 0 15px;
}
dialog fieldset {
  border: 1px solid #505d41;
  margin: 0 0 20px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 7px;
}
dialog fieldset label {
  display: flex;
  align-items: center;
  font-size: 12px;
  margin: 0;
}
dialog legend {
  font-size: 10px;
  color: #a6986a;
}
dialog small {
  display: block;
  color: #829279;
  font-size: 10px;
  line-height: 1.6;
  margin-top: 14px;
}
.primary {
  width: 100%;
  background: linear-gradient(#9a713e, #694b2c);
  color: #fff1cf;
  padding: 13px;
}
#entry-error {
  color: #eead83;
}
.dialog-close {
  float: right;
  font-size: 11px;
  padding: 6px;
  background: transparent;
  border-color: #596449;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 85vw;
  padding: 13px 22px;
  background: #12241bf2;
  color: #ebd8a9;
  box-shadow: 0 6px 30px #0007;
  border: 1px solid #938151;
  border-radius: 3px;
  font-size: 12px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
#toast.visible {
  opacity: 1;
}
[hidden] {
  display: none !important;
}
@media (max-width: 850px) {
  .masthead {
    height: 75px;
  }
  .wordmark span {
    font-size: 23px;
  }
  main {
    padding: 16px;
  }
  .game-layout {
    grid-template-columns: minmax(0, 640px);
    gap: 14px;
  }
  .side-panel {
    display: grid;
    grid-template-columns: 190px 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .commander-card {
    grid-row: 1/4;
    padding: 13px;
  }
  .tabs {
    border-top: 0;
  }
  .tab-panel {
    max-height: 275px;
    overflow: auto;
  }
  .scroll-list {
    max-height: 210px;
  }
  .leave {
    grid-column: 2;
  }
  .chat-log {
    font-size: clamp(9px, 1.7vw, 11px);
  }
  .mobile-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    color: #7f927a;
    font-size: 10px;
  }
  .mobile-controls span {
    text-align: right;
    line-height: 1.8;
  }
  .footnote {
    max-width: 500px;
    margin: 17px auto;
  }
}
@media (max-width: 480px) {
  main {
    padding: 10px 7px 25px;
  }
  .masthead {
    padding: 0 12px;
    height: 64px;
  }
  .portal-link {
    font-size: 10px;
  }
  .wordmark span {
    font-size: 19px;
    letter-spacing: 0.06em;
  }
  .wordmark small {
    font-size: 8px;
  }
  .quiet {
    padding: 7px;
    font-size: 10px;
  }
  .connection-line {
    font-size: 9px;
    margin: 5px 4px 10px;
  }
  .action-bar button {
    font-size: 10px;
    padding: 10px 2px;
  }
  kbd {
    display: none;
  }
  .side-panel {
    grid-template-columns: 130px 1fr;
  }
  .commander-card {
    padding: 10px;
  }
  h1 {
    font-size: 16px;
  }
  .stats {
    font-size: 10px;
    gap: 6px;
  }
  #player-class {
    font-size: 9px;
  }
  .tab-panel {
    padding: 8px;
  }
  .tabs button {
    font-size: 10px;
    padding: 10px 0;
  }
  .row {
    font-size: 10px;
  }
  .chat-form {
    gap: 5px;
  }
  .chat-form input {
    font-size: 10px;
  }
  .chat-form button {
    font-size: 10px;
  }
  .chat-log {
    font-size: 8px;
  }
  .stage-notice {
    font-size: 11px;
    padding: 12px;
  }
  .dpad {
    grid-template-columns: repeat(3, 45px);
    grid-template-rows: repeat(2, 38px);
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.nearby-list {
  font-size: 10px;
  line-height: 1.7;
  color: #91b69a;
  margin-top: 7px;
}

.render-options {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #8f9d82;
  margin-top: 8px;
}
.render-options select {
  font: inherit;
  background: #1a241c;
  color: #d5c899;
  border: 1px solid #535d41;
  border-radius: 3px;
  padding: 4px;
}
.render-options span {
  margin-left: auto;
  color: #677a63;
}

.action-bar {
  grid-template-columns: repeat(5, 1fr);
}
.tabs {
  grid-template-columns: repeat(6, 1fr);
}
.action-bar {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.action-bar button {
  min-width: 0;
  overflow-wrap: anywhere;
}
.action-bar button#interact-button {
  grid-column: auto;
}
.progression-card,
.spell-card {
  border-bottom: 1px solid #4b543a;
  padding: 0 0 12px;
  margin-bottom: 12px;
  min-width: 0;
}
.progression-card summary,
.spell-card summary,
.source-note summary {
  color: #d0bd8b;
  font-size: 12px;
  cursor: pointer;
  padding: 7px 0;
}
.progression-summary {
  color: #a8b89c;
  font-size: 11px;
  line-height: 1.65;
  margin: 6px 0;
}
.career-stats {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}
.career-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
}
.career-stat span {
  min-width: 0;
}
.career-stat button {
  flex-shrink: 0;
  font-size: 11px;
  padding: 6px;
}
.source-note {
  margin-top: 8px;
}
.source-note p {
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  color: #91a18a;
}
.spell-card select {
  width: 100%;
  min-width: 0;
  margin: 6px 0;
  color: #e4d5ac;
  background: #152019;
  border: 1px solid #5e6649;
  padding: 8px 4px;
  font: inherit;
  font-size: 11px;
}
.nearby-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 2px;
  font-size: inherit;
}
#promote-button {
  width: 100%;
  font-size: 11px;
}
.story-entry {
  font-size: 11px;
  border-bottom: 1px solid #3d4835;
  padding: 9px 0;
}
.story-entry summary {
  cursor: pointer;
  color: #c4b682;
}
.story-entry p {
  white-space: pre-wrap;
  line-height: 1.8;
  color: #d2d4bc;
}
#story-summary {
  max-height: 180px;
  font-size: 11px;
  margin: 0 0 10px;
}

/* Original GameLib UI crops. Pixel provenance: ui/skins/manifest.json.
   Web panel placement and responsive behavior are reconstructed. */
.native-controls {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.original-ui .native-controls {
  display: block;
}
.native-controls button {
  position: absolute;
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: transparent;
  background: transparent;
  pointer-events: auto;
  text-shadow: none;
}
.original-ui {
  --paper-ink: #2b1a0e;
  --paper-muted: #4e381f;
  --paper-line: #967145;
  color: #ead8ad;
  background: #16120e;
  font-family: "Gulim", "Dotum", "Malgun Gothic", system-ui, sans-serif;
}
.original-ui .masthead {
  max-width: 1000px;
  height: 56px;
  padding: 0 12px;
  border-color: #715338;
}
.original-ui .wordmark span {
  color: #f1d29d;
  font-size: 21px;
  letter-spacing: 0.12em;
}
.original-ui .wordmark small {
  color: #c6ae84;
}
.original-ui main {
  max-width: 1000px;
  padding: 12px 12px 24px;
}
.original-ui .connection-line {
  margin-bottom: 8px;
  color: #cfbd98;
}
.original-ui .game-layout {
  grid-template-columns: minmax(0, 640px) minmax(244px, 280px);
  gap: 10px;
}
.original-ui button {
  border-radius: 0;
  border-color: #c29a67 #604126 #604126 #c29a67;
  background-color: #7a4d29;
  background-image:
    linear-gradient(#2b100980, #2b1009a6),
    url("assets/ui/skins/paper-dark@2x.png?v=v3-3bf6d39");
  background-size:
    auto,
    80px 80px;
  color: #fff0ca;
  box-shadow:
    inset 1px 1px #e3bf8659,
    inset -1px -1px #27130f80;
  text-shadow: 1px 1px #30150e;
}
.original-ui button:hover {
  border-color: #f6dba4;
  filter: brightness(1.12);
}
.original-ui button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.original-ui .quiet {
  background: #211a13;
  border-color: #7e6240;
  color: #d6c19b;
  text-shadow: none;
}
.original-ui .side-panel,
.original-ui dialog {
  color: var(--paper-ink);
  background: #caa16d url("assets/ui/skins/paper@2x.png?v=v3-3bf6d39") repeat;
  background-size: 80px 80px;
  border: 8px solid #9c7544;
  border-image: url("assets/ui/skins/window-border@2x.png?v=v3-3bf6d39") 8 / 8px round;
  border-radius: 0;
  box-shadow: 0 8px 24px #0006;
}
.original-ui .commander-card {
  padding: 12px;
  border-bottom: 1px solid var(--paper-line);
}
.original-ui .eyebrow,
.original-ui .field-label,
.original-ui .panel-caption,
.original-ui #player-class,
.original-ui .stats,
.original-ui .progression-summary,
.original-ui .nearby-list,
.original-ui dialog p,
.original-ui dialog small,
.original-ui dialog legend,
.original-ui .source-note p {
  color: var(--paper-muted);
}
.original-ui h1,
.original-ui dialog h2 {
  color: #2a170b;
  font-family: inherit;
  font-weight: 700;
  text-shadow: 0 1px #e8c994;
}
.original-ui h1 {
  font-size: 19px;
}
.original-ui .target-label {
  color: #39230f;
  border-color: var(--paper-line);
  min-height: 40px;
  line-height: 1.6;
}
.original-ui .meter {
  border-radius: 0;
  border: 1px solid #5f4128;
  height: 20px;
  background: #2c211a;
  box-shadow:
    inset 1px 1px #0008,
    0 1px #edcf98;
}
.original-ui .meter span {
  font:
    bold 11px/18px "Gulim",
    "Dotum",
    sans-serif;
}
.original-ui .meter.hp i {
  background: linear-gradient(#e79b53, #ad4430 50%, #702b24);
}
.original-ui .meter.mp i {
  background: linear-gradient(#a6d5df, #4d80ab 50%, #344b73);
}
.original-ui .tabs {
  border: 0;
  border-bottom: 1px solid var(--paper-line);
  gap: 2px;
  padding: 4px;
}
.original-ui .tabs button {
  padding: 9px 1px;
  font-size: 12px;
  border: 1px solid #7d572c;
}
.original-ui .tabs button[aria-selected="true"] {
  color: #2a190b;
  background: #e6bd7c;
  text-shadow: 0 1px #f4d5a5;
  box-shadow: inset 1px 1px #fff4d3;
}
.original-ui .tab-panel {
  padding: 10px;
}
.original-ui .tab-panel input,
.original-ui dialog input,
.original-ui .spell-card select,
.original-ui .render-options select {
  background: #edcf98;
  color: #291a0e;
  border: 1px solid #805931;
  border-radius: 0;
  box-shadow: inset 1px 1px #5b3a2029;
}
.original-ui input::placeholder {
  color: #725538;
}
.original-ui .row {
  color: #2c1b0e;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #a98550;
  min-height: 42px;
  box-shadow: none;
  text-shadow: none;
  font-size: 12px;
}
.original-ui .row small,
.original-ui .row .badge {
  color: #503923;
  font-size: 10px;
}
.original-ui .row:hover,
.original-ui .row.active {
  background: #8b572421;
  color: #261708;
}
.original-ui .dialogue,
.original-ui .story-entry summary,
.original-ui .story-entry p,
.original-ui .progression-card summary,
.original-ui .spell-card summary,
.original-ui .source-note summary {
  color: #38220f;
}
.original-ui .progression-card,
.original-ui .spell-card,
.original-ui .story-entry {
  border-color: #a98550;
}
.original-ui .scroll-list {
  scrollbar-color: #947043 #d1ad78;
}
.original-ui .leave {
  width: calc(100% - 20px);
  margin: 0 10px 10px;
  min-height: 38px;
  font-size: 12px;
}
.original-ui .action-bar {
  margin-top: 6px;
  gap: 4px;
}
.original-ui .action-bar button {
  min-height: 42px;
}
.original-ui .chat-form input {
  border-radius: 0;
  background: #261b13;
  color: #fff0cf;
  border-color: #9b7549;
  box-shadow: inset 1px 1px #0007;
}
.original-ui .chat-form input::placeholder {
  color: #c2ab86;
}
.original-ui .native-controls button,
.original-ui .native-controls button:hover {
  background: transparent;
  box-shadow: none;
  border: 0;
  color: transparent;
  text-shadow: none;
}
.original-ui .native-controls button:hover {
  background: #ffdc8a1c;
  box-shadow: inset 0 0 0 1px #f2d492;
}
.render-options {
  flex-wrap: wrap;
  font-size: 13px;
}
.render-options select {
  flex: 1;
  min-width: 150px;
  min-height: 44px;
  font-size: 14px;
  padding: 8px;
}
.quality-note {
  font-size: 12px;
}
.viewport-options {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.viewport-options button {
  flex: 1;
  min-height: 44px;
}
.travellers-list {
  display: grid;
  gap: 6px;
  max-height: min(50vh, 300px);
  overflow: auto;
}
.travellers-list button {
  min-height: 44px;
  text-align: left;
}
@media (max-width: 850px) {
  .original-ui .game-layout {
    grid-template-columns: minmax(0, 640px);
  }
}
:root .spawn-source {
  font-size: 11px;
  color: #d9c79f;
  margin-inline-start: auto;
}

/* The native frame is the game view. Web support remains an explicit popup. */
#native-touch-toggle,
.native-web-panel-heading,
#native-window-layer {
  display: none;
}
body.native-layout {
  min-height: 0;
  height: var(--mobile-vh, 100dvh);
  overflow: hidden;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  background: #050707;
}
body.native-layout #native-access-dock {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: none;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 max(6px, env(safe-area-inset-right)) 0
    max(6px, env(safe-area-inset-left));
  border: 0;
  gap: 6px;
  background: #050707;
}
body.native-layout #native-access-dock .wordmark,
body.native-layout #native-access-dock #music-button,
body.native-layout #native-access-dock #help-button {
  display: none;
}
body.native-layout #native-access-dock .portal-link {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  margin-right: auto;
  font-size: 12px;
}
body.native-layout #native-access-dock .button-row {
  display: flex;
  align-items: center;
  flex: none;
  gap: 5px;
}
body.native-layout #native-touch-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 44px;
  padding: 5px 8px;
  font-size: 12px;
}
body.native-layout #native-game-windows {
  min-width: 72px;
  height: 44px;
  min-height: 44px;
  padding: 3px;
  color: #f1dfb0;
  background: #211d17;
  border: 1px solid #9a8255;
  font:
    12px Gulim,
    "굴림",
    sans-serif;
}
body.native-layout main {
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 max(4px, env(safe-area-inset-right))
    max(2px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
body.native-layout .connection-line,
body.native-layout .footnote,
body.native-layout .action-bar,
body.native-layout .mobile-controls,
body.native-layout .mobile-toolbar,
body.native-layout .chat-form,
body.native-layout .chat-log,
body.native-layout #game-side-panel {
  display: none;
}
body.native-layout .game-layout {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "world";
  align-items: stretch;
  gap: 0;
}
body.native-layout .play-column {
  display: contents;
}
body.native-layout #stage {
  grid-area: world;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  align-self: stretch;
  position: relative;
  overflow: hidden;
  box-shadow: none;
  background: #050707;
  container-type: size;
}
body.native-layout #world {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(100cqw, calc(100cqh * 4 / 3));
  height: min(100cqh, calc(100cqw * 3 / 4));
  max-width: none;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
}
body.native-layout .native-controls {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
body.native-layout .native-controls button,
body.native-layout .native-hit-button {
  position: absolute;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  text-shadow: none;
  font-size: 0;
  pointer-events: auto;
}
body.native-layout .native-controls button:hover,
body.native-layout .native-hit-button:hover {
  background: transparent;
  box-shadow: none;
  filter: brightness(1.08);
}
body.native-layout .native-command-button:hover,
body.native-layout .native-command-button:disabled {
  opacity: 1;
  filter: none;
}

/* Web access controls stay outside the source frame. Reuse the existing five
   mobile dock cells so command back/paging cannot spill into a clipped row. */
@media (max-width: 700px), (max-width: 950px) and (max-height: 500px), (max-width: 1100px) and (pointer: coarse) {
  body.native-layout #native-access-dock #native-command-back:not([hidden]),
  body.native-layout #native-access-dock #native-command-previous:not([hidden]),
  body.native-layout #native-access-dock #native-command-next:not([hidden]) {
    display: inline-flex;
    grid-row: 1;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 2px;
    align-items: center;
    justify-content: center;
    font-size: 0;
  }
  body.native-layout #native-access-dock #native-command-back { grid-column: 3; }
  body.native-layout #native-access-dock #native-command-back::before { content: "이전"; font-size: 12px; }
  body.native-layout #native-access-dock #native-command-previous { grid-column: 1; }
  body.native-layout #native-access-dock #native-command-previous::before { content: "◀"; font-size: 20px; }
  body.native-layout #native-access-dock #native-command-next { grid-column: 2; }
  body.native-layout #native-access-dock #native-command-next::before { content: "▶"; font-size: 20px; }
  body.native-layout:has(#native-command-back:not([hidden])) #native-access-dock #native-menu-toggle,
  body.native-layout:has(#native-window-close:not([hidden])) #native-access-dock #native-quality-button,
  body.native-layout:has(#native-command-previous:not([hidden])) #native-access-dock [data-game-fullscreen],
  body.native-layout:has(#native-command-previous:not([hidden])) #native-access-dock #native-touch-toggle {
    display: none;
  }
}
body.native-layout .native-hit-button:focus-visible,
body.native-layout .native-controls button:focus-visible {
  outline: 1px solid #f3d29a;
  outline-offset: -1px;
}
body.native-layout #native-window-layer {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  image-rendering: pixelated;
}
body.native-layout .native-window {
  position: absolute;
  pointer-events: auto;
  image-rendering: pixelated;
}
body.native-layout .native-window-image {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  image-rendering: pixelated;
}
body.native-layout #chat-form.native-chat-input {
  display: block;
  position: absolute;
  z-index: 10;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
body.native-layout #chat-log {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0;
  padding: 1px 2px;
  overflow: hidden;
  z-index: 9;
  pointer-events: none;
  background: transparent;
  color: #f4dfb4;
  font-family: Gulim, "굴림", sans-serif;
  font-size: var(--native-chat-font-size, 12px);
  line-height: 1.15;
}
body.native-layout #chat-log > * {
  flex: none;
}
body.native-layout #chat-log > :nth-last-child(n + 3) {
  display: none;
}
body.native-layout:has(#chat-input:focus) #chat-log {
  visibility: hidden;
}
body.native-layout #chat-form.native-chat-input input {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #f4dfb4;
  text-shadow: 1px 1px #24160d;
  font-family: "Gulim", "Dotum", sans-serif;
  font-size: var(--native-chat-font-size, 12px) !important;
  line-height: 1.2;
}
body.native-layout #chat-form.native-chat-input label,
body.native-layout #chat-form.native-chat-input button,
body.native-layout #chat-form.native-chat-input[hidden],
body.native-layout #native-window-layer [hidden] {
  display: none;
}
body.native-layout.native-web-panel-open #game-side-panel {
  display: block;
  position: fixed;
  z-index: 70;
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 24px));
  max-height: calc(var(--mobile-vh, 100dvh) - 64px);
  overflow: auto;
  overscroll-behavior: contain;
}
body.native-layout.native-web-panel-open .native-web-panel-heading {
  display: flex;
  position: sticky;
  z-index: 2;
  top: 0;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 2px 8px;
  border-bottom: 1px solid #977244;
  background: #d4ae75;
  color: #2b1a0e;
}
body.native-layout #native-web-close {
  min-width: 44px;
  min-height: 44px;
}
body.native-layout.native-web-panel-open #game-side-panel .commander-card {
  display: block;
}
body.native-layout.native-web-panel-open #game-side-panel > .tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
body.native-layout.native-web-panel-open
  #game-side-panel
  > .tab-panel:not([hidden]),
body.native-layout.native-web-panel-open #game-side-panel > .leave {
  display: block;
}
body.native-layout.native-web-panel-open #game-side-panel .scroll-list {
  max-height: none;
  overflow: visible;
}

/* Original Wlib scene24: fixed 397×300 source geometry, scaled as one surface.
   Transparent controls and focus indication are web accessibility adapters. */
body.native-layout #entry-dialog.native-entry {
  width: min(
    397px,
    calc(100vw - 16px),
    calc((var(--mobile-vh, 100dvh) - 16px) * 397 / 300)
  );
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: 397 / 300;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
body.native-layout #entry-dialog.native-entry::backdrop {
  background: #0008;
  backdrop-filter: none;
}
body.native-layout #entry-form.native-entry-surface {
  position: absolute;
  inset: 0 auto auto 0;
  width: 397px;
  height: 300px;
  margin: 0;
  padding: 0;
  transform: scale(var(--native-entry-scale, 1));
  transform-origin: 0 0;
  image-rendering: pixelated;
}
body.native-layout #entry-form .native-entry-bitmap {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 397px;
  height: 300px;
  pointer-events: none;
  user-select: none;
  image-rendering: pixelated;
}
body.native-layout #entry-form .native-entry-portrait {
  z-index: 1;
  pointer-events: none;
  user-select: none;
  image-rendering: pixelated;
}
body.native-layout #entry-form > h2,
body.native-layout #entry-form > p:not(#entry-error),
body.native-layout #entry-form > label[for="name-input"],
body.native-layout #entry-form > small,
body.native-layout #entry-form legend {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body.native-layout #entry-form fieldset {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 397px;
  height: 300px;
  margin: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
}
body.native-layout #entry-form .native-entry-card {
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  pointer-events: auto;
}
body.native-layout #entry-form .native-entry-card input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
body.native-layout #entry-form .native-entry-card:has(input:focus-visible) {
  outline: 1px solid #542e11;
  outline-offset: -2px;
}
body.native-layout #entry-form .native-entry-legacy {
  display: none;
}
body.native-layout #entry-form #name-input {
  position: absolute;
  left: 254px;
  top: 241px;
  z-index: 3;
  width: 87px;
  height: 15px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  background: transparent;
  box-shadow: none;
  color: #241407;
  font:
    12px/15px "Gulim",
    "Dotum",
    sans-serif;
}
body.native-layout #entry-form #enter-button {
  z-index: 3;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  font-size: 0;
  text-shadow: none;
}
body.native-layout #entry-form #enter-button:hover {
  background: transparent;
  box-shadow: none;
}
body.native-layout #entry-form #enter-button:focus-visible,
body.native-layout #entry-form #name-input:focus-visible {
  outline: 1px solid #542e11;
}
body.native-layout #entry-form #entry-error {
  position: absolute;
  left: 0;
  top: 304px;
  z-index: 4;
  width: 397px;
  margin: 0;
  padding: 2px;
  box-sizing: border-box;
  background: #18110de8;
  color: #ffe5c9;
  font:
    calc(12px / var(--native-entry-scale, 1)) / 1.5 "Gulim",
    "Dotum",
    sans-serif;
}
body.native-layout #entry-form #entry-error:empty {
  display: none;
}
