:root {
  color-scheme: light;
  font-family: Georgia, Cambria, serif;
  color: #174a49;
  background: #174f62;
  --hud: #fff9e9e8;
  --hud-border: #f2dfbba8;
  --teal: #0f6162;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; min-width: 0; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; cursor: pointer; }
.island-app { position: relative; width: 100%; height: 100dvh; min-height: 100%; overflow: hidden; background: #237f98; }
.topbar { position: absolute; z-index: 8; top: calc(14px + var(--safe-top)); right: calc(16px + var(--safe-right)); left: calc(16px + var(--safe-left)); display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 12px 7px 8px; border: 1px solid var(--hud-border); border-radius: 16px; background: var(--hud); box-shadow: 0 7px 24px #12384628; letter-spacing: .14em; backdrop-filter: blur(10px); pointer-events: auto; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 1px; font: 700 8px Arial, sans-serif; letter-spacing: .12em; white-space: nowrap; }
.brand-star { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 10px; background: #0d5b5c; color: #f7d379; font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; pointer-events: auto; }
.hud-button, .viewport-map { min-height: 44px; border: 1px solid #d8efd9ad; border-radius: 999px; background: #0f6162e8; color: white; padding: 10px 15px; box-shadow: 0 7px 24px #12384635; font: 700 12px Arial, sans-serif; letter-spacing: .04em; backdrop-filter: blur(9px); }
.hud-button:focus-visible, .viewport-map:focus-visible, .drawer-close:focus-visible, .destination-list button:focus-visible, .region-guide button:focus-visible, .destination-action button:focus-visible { outline: 3px solid #ffd67c; outline-offset: 2px; }
.workspace, .play-panel, .island-viewport { position: absolute; inset: 0; }
.workspace { overflow: clip; }
.play-panel { min-width: 0; overflow: hidden; background: #237f98; }
.play-title { position: absolute; z-index: 5; top: calc(78px + var(--safe-top)); left: calc(16px + var(--safe-left)); display: grid; width: max-content; max-width: calc(100% - 32px - var(--safe-left) - var(--safe-right)); padding: 8px 12px 9px; border: 1px solid var(--hud-border); border-radius: 14px; background: var(--hud); box-shadow: 0 7px 24px #12384624; backdrop-filter: blur(9px); pointer-events: none; }
.play-title span, .eyebrow { color: #a7633b; font: 700 8px Arial, sans-serif; letter-spacing: .14em; }
.play-title strong { margin-top: 2px; color: #174a49; font-size: 18px; line-height: 1.05; }
.play-title small { margin-top: 3px; color: #46736b; font: 9px Arial, sans-serif; }
.island-viewport { width: 100%; height: 100%; min-height: 0; overflow: hidden; background: #237f98; touch-action: none; }
.island-terrain-layer { position: absolute; inset: 0; overflow: hidden; background: #1f718d; pointer-events: none; }
.island-chunk-plane { position: absolute; left: 0; top: 0; width: 1536px; height: 2048px; transform-origin: 0 0; will-change: transform; }
.island-base-land { position: absolute; inset: 0; background: #639364; }
.island-chunk-plane canvas { position: absolute; display: block; }
#island-world { position: relative; display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.island-loading { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; background: #155e71e8; color: #fff6d5; text-align: center; font: 700 15px/1.4 Arial, sans-serif; pointer-events: none; }
.island-loading-content { display: grid; justify-items: center; gap: 12px; }
.island-load-fallback { min-height: 44px; display: inline-flex; align-items: center; border: 1px solid #fff3c0; border-radius: 999px; padding: 9px 15px; background: #fff9e9; color: #14544e; text-decoration: none; font: 700 12px Arial, sans-serif; pointer-events: auto; }
.island-load-fallback:focus-visible { outline: 3px solid #ffd67c; outline-offset: 3px; }
.island-loading[hidden], .island-debug-panel[hidden] { display: none; }
.island-debug-panel { position: absolute; top: calc(132px + var(--safe-top)); right: calc(12px + var(--safe-right)); z-index: 6; max-width: min(430px, calc(100% - 24px)); margin: 0; padding: 9px 11px; border: 1px solid #edffb6; border-radius: 8px; background: #092e37dc; color: #f4ffdc; white-space: pre-wrap; font: 10px/1.45 ui-monospace, Consolas, monospace; pointer-events: none; }
.viewport-badge { position: absolute; z-index: 4; top: calc(16px + var(--safe-top)); left: 50%; transform: translateX(-50%); padding: 7px 10px; border: 1px solid var(--hud-border); border-radius: 16px; background: #fdf5d8d9; color: #1c5a56; font: 700 9px Arial, sans-serif; letter-spacing: .05em; white-space: nowrap; pointer-events: none; backdrop-filter: blur(8px); }
.joystick { position: absolute; z-index: 5; bottom: calc(20px + var(--safe-bottom)); left: calc(18px + var(--safe-left)); display: grid; justify-items: center; gap: 3px; color: white; font: 700 9px Arial, sans-serif; letter-spacing: .09em; touch-action: none; user-select: none; }
.joystick-track { position: relative; width: 92px; height: 92px; border: 2px solid #fff4ca; border-radius: 50%; background: #0f6469b8; box-shadow: 0 4px 18px #163e4a77; backdrop-filter: blur(6px); }
.joystick-knob { position: absolute; left: 50%; top: 50%; width: 35px; height: 35px; transform: translate(-50%, -50%); border: 2px solid white; border-radius: 50%; background: #d9ae6b; }
.viewport-map { position: absolute; z-index: 5; right: calc(18px + var(--safe-right)); bottom: calc(26px + var(--safe-bottom)); border-color: #fff3c0; }
.destination-action { position: absolute; z-index: 7; right: calc(18px + var(--safe-right)); bottom: calc(86px + var(--safe-bottom)); display: grid; justify-items: end; gap: 5px; pointer-events: auto; }
.destination-action[hidden] { display: none; }
.destination-action span { padding: 6px 10px; border: 1px solid var(--hud-border); border-radius: 10px; background: var(--hud); color: #174a49; font: 700 10px Arial, sans-serif; }
.destination-action button { min-height: 46px; border: 1px solid #fff3c0; border-radius: 999px; padding: 10px 17px; background: #a75c35; color: white; box-shadow: 0 7px 24px #12384645; font: 800 13px Arial, sans-serif; }
.destination-action button:disabled { opacity: .7; cursor: wait; }
.play-footer { position: absolute; z-index: 5; top: calc(148px + var(--safe-top)); left: calc(16px + var(--safe-left)); max-width: min(370px, calc(100% - 32px)); padding: 7px 10px; border: 1px solid #dbe9d686; border-radius: 11px; background: #104e55c9; color: #f9f5de; box-shadow: 0 5px 18px #1238462e; font: 10px/1.35 Arial, sans-serif; backdrop-filter: blur(8px); pointer-events: none; }
.play-footer small { display: none; }
.drawer-scrim { position: absolute; z-index: 10; inset: 0; visibility: hidden; border: 0; background: #092c3a00; opacity: 0; transition: opacity .22s ease, visibility 0s linear .22s, background .22s ease; cursor: default; }
.drawer-scrim.is-open { visibility: visible; background: #092c3a72; opacity: 1; transition-delay: 0s; }
.side-panel { position: absolute; z-index: 11; top: calc(12px + var(--safe-top)); right: calc(12px + var(--safe-right)); bottom: calc(12px + var(--safe-bottom)); width: min(380px, calc(100% - 24px)); display: flex; flex-direction: column; padding: 22px; border: 1px solid #eadfc8; border-radius: 24px; background: #fff9edfa; box-shadow: 0 18px 70px #092c3a70; transform: translateX(calc(100% + 30px)); opacity: 0; visibility: hidden; transition: transform .25s ease, opacity .2s ease, visibility 0s linear .25s; }
.side-panel.is-open { transform: translateX(0); opacity: 1; visibility: visible; transition-delay: 0s; }
.drawer-handle { display: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.drawer-head h2 { margin: 5px 0 0; color: #174a49; font-size: 26px; }
.drawer-close { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid #d8cdb6; border-radius: 50%; background: #f2ead9; color: #174a49; font-size: 28px; line-height: 1; }
.drawer-intro { margin: 12px 0 3px; color: #4c746c; font: 12px/1.5 Arial, sans-serif; }
.drawer-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 3px 2px 8px; }
.destination-list { display: grid; gap: 8px; margin-top: 15px; }
.destination-list button, .region-guide button { width: 100%; min-height: 48px; border: 1px solid #d9d0b6; border-radius: 13px; background: #fffdf5; color: #14544e; padding: 11px 13px; text-align: left; }
.destination-list button strong, .destination-list button small { display: block; }
.destination-list button small { margin-top: 3px; color: #687d70; font: 10px Arial, sans-serif; }
.region-guide { display: grid; gap: 8px; margin-top: 20px; border-top: 1px solid #d6ccb3; padding-top: 15px; }
.region-guide > strong { font-size: 15px; }
.region-guide > div { display: grid; gap: 6px; }
.region-guide button { font: 12px Arial, sans-serif; background: #e8eee1; }
.local-note { margin: 18px 1px 0; color: #747c6a; font: 11px/1.5 Arial, sans-serif; }
.map-dialog { width: min(450px, calc(100vw - 22px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 17px; border: 1px solid #e3d9bf; border-radius: 18px; background: #fff9eb; color: #174a49; box-shadow: 0 10px 50px #0c343c69; }
.map-dialog::backdrop { background: #082c39ad; }
.map-head { display: flex; justify-content: space-between; align-items: start; }
.map-head h2 { margin: 4px 0; font-size: 25px; }
.map-head button { border: 0; background: transparent; color: #174a49; font-size: 32px; }
.map-dialog p, .map-legend { font: 12px/1.4 Arial, sans-serif; }
#island-overview { display: block; width: min(100%, 360px); height: auto; margin: 12px auto; border-radius: 12px; background: #1c829e; cursor: crosshair; }
.map-legend { display: flex; flex-wrap: wrap; gap: 11px; justify-content: space-around; }

@media (max-width: 760px) {
  .topbar { top: calc(8px + var(--safe-top)); right: calc(9px + var(--safe-right)); left: calc(9px + var(--safe-left)); gap: 7px; }
  .brand { gap: 7px; padding: 5px 9px 5px 5px; border-radius: 14px; }
  .brand-star { width: 30px; height: 30px; }
  .brand strong { font-size: 14px; }
  .brand small { max-width: 122px; overflow: hidden; font-size: 7px; text-overflow: ellipsis; }
  .topbar-actions { gap: 6px; }
  .hud-button { min-width: 44px; padding: 9px 11px; }
  .hud-button span { display: none; }
  .play-title { top: calc(60px + var(--safe-top)); left: calc(10px + var(--safe-left)); padding: 7px 10px 8px; }
  .play-title strong { font-size: 16px; }
  .play-title small { display: none; }
  .play-footer { top: calc(111px + var(--safe-top)); left: calc(10px + var(--safe-left)); max-width: calc(100% - 20px - var(--safe-left) - var(--safe-right)); padding: 6px 9px; font-size: 9px; }
  .viewport-badge { top: auto; right: calc(12px + var(--safe-right)); bottom: calc(88px + var(--safe-bottom)); left: auto; transform: none; max-width: 155px; overflow: hidden; text-overflow: ellipsis; }
  .joystick { bottom: calc(16px + var(--safe-bottom)); left: calc(14px + var(--safe-left)); }
  .joystick-track { width: 88px; height: 88px; }
  .viewport-map { right: calc(14px + var(--safe-right)); bottom: calc(22px + var(--safe-bottom)); min-width: 74px; padding: 10px 13px; }
  .destination-action { right: calc(12px + var(--safe-right)); bottom: calc(78px + var(--safe-bottom)); }
  .side-panel { top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(72dvh, 650px); padding: 10px 16px calc(16px + var(--safe-bottom)); border-width: 1px 0 0; border-radius: 24px 24px 0 0; transform: translateY(calc(100% + 20px)); }
  .side-panel.is-open { transform: translateY(0); }
  .drawer-handle { display: block; width: 42px; height: 5px; margin: 0 auto 10px; border-radius: 99px; background: #c7bca6; }
  .drawer-head h2 { font-size: 22px; }
  .drawer-intro { margin-top: 8px; }
  .destination-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .destination-list button { min-height: 58px; }
}

@media (max-width: 370px) {
  .brand small { display: none; }
  .brand { padding-right: 8px; }
  .destination-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .side-panel, .drawer-scrim { transition-duration: .01ms; }
}
