* { box-sizing: border-box; }
html, body, main { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { font-family: system-ui, sans-serif; background: #312d30; color: #fff9ea; }
canvas { display: block; width: 100%; height: 100%; outline: none; }

#loader {
  position: absolute;
  inset: 0;
  z-index: 3;
  isolation: isolate;
  overflow-y: auto;
  background: radial-gradient(ellipse at 72% 32%, #596562, #312d30 74%);
  transition: opacity .28s ease-out;
}
#loader.out { opacity: 0; pointer-events: none; }
.loading-art, #loader::before { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.loading-art { z-index: -2; object-fit: cover; object-position: 67% center; }
.loading-art:not([src]) { visibility: hidden; }
#loader::before {
  content: "";
  z-index: -1;
  background: linear-gradient(90deg, #29262bd9, #302c306b 32%, transparent 62%),
              linear-gradient(0deg, #302c30a6, transparent 29%);
}
.loading-layout {
  --gutter: clamp(24px, 5.4vw, 108px);
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  min-height: 100%;
  gap: 12px;
  padding: max(26px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.loading-credit {
  justify-self: center;
  color: #fff5dc;
  font: 500 clamp(11px, .83vw, 14px)/1.3 system-ui, sans-serif;
  text-shadow: 0 1px 3px #14112d, 0 0 6px #14112d;
}
.loading-main { width: min(38vw, 490px); text-shadow: 0 2px 4px #10112b; }
.word { display: block; width: 100%; height: auto; filter: drop-shadow(0 5px 2px #13122c99); }
.tag { margin: 0 0 clamp(24px, 5vh, 58px); font-size: clamp(14px, 1.55vw, 24px); font-weight: 800; font-style: italic; }
#status { margin: 0 0 9px; font-weight: 750; font-size: clamp(15px, 1.25vw, 20px); }
.rail {
  width: min(100%, 365px);
  height: 7px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff8e649;
}
.rail i { display: block; width: 0; height: 100%; border-radius: inherit; background: #ffcf37; transition: width .16s; }
.load-tip { max-width: 37ch; margin: 12px 0 0; color: #f7ebd8; font-size: clamp(13px, 1.06vw, 17px); line-height: 1.45; }
#retry, #download-retry {
  min-height: 42px;
  padding: 8px 18px;
  border: 1px solid #fff4c6;
  border-radius: 22px;
  background: #ffe396;
  color: #312d30;
  font: 750 15px/1.2 system-ui, sans-serif;
  cursor: pointer;
}
#retry { margin-top: 14px; }
#download-retry { position: absolute; z-index: 6; left: 50%; top: max(18px, env(safe-area-inset-top)); transform: translateX(-50%); }
#retry:focus-visible, #download-retry:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.development-notice {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.3vw, 22px);
  width: fit-content;
  max-width: 100%;
  padding: clamp(12px, 1.3vw, 19px) clamp(15px, 1.5vw, 24px);
  border: 1px solid #fffaee38;
  border-radius: 19px;
  background: #302c30b3;
  color: #f6f0ef;
  font-size: clamp(13px, .97vw, 16px);
  line-height: 1.46;
}
.development-notice strong { display: block; color: #ffdf85; font-size: 1.12em; }
.development-notice p { margin: 0; }
.notice-icon { flex: none; display: grid; place-items: center; width: 2.05em; height: 2.05em; border: 2px solid #ffdf85; border-radius: 50%; color: #ffdf85; font-size: 1.25em; font-weight: 800; line-height: 1; }
#full { position: absolute; right: 10px; bottom: 10px; width: 37px; height: 33px; border: 1px solid #f9eec074; border-radius: 6px; background: #142b3bd9; color: #fff1c6; font: 24px/1 system-ui; cursor: pointer; opacity: .65; }
#full:is(:hover, :focus-visible) { opacity: 1; outline: 2px solid #ffce65; }
#full.native-hit { right: auto; bottom: auto; opacity: 0; padding: 0; border: 0; z-index: 2; }
#full.native-hit:focus-visible { opacity: 1; background: transparent; color: transparent; outline: 2px solid #ffce65; }

@media (orientation: portrait) {
  .loading-art { object-position: 69% center; }
  
  #loader::before { background: linear-gradient(0deg, #302c30ec 4%, #302c30ba 44%, transparent 80%); }
  .loading-layout { align-items: end; gap: clamp(12px, 2vh, 24px); padding-top: 33vh; }
  .loading-main { width: 100%; }
  .word { width: min(78%, 420px); }
  .tag { margin: 0 0 clamp(15px, 2.6vh, 30px); }
  .notice-icon { align-self: flex-start; }
}
@media (orientation: portrait) and (max-height: 680px) {
  .loading-layout { --gutter: 16px; padding-top: 21vh; padding-bottom: max(12px, env(safe-area-inset-bottom)); gap: 12px; }
  #loader::before { background: linear-gradient(0deg, #302c30ed 12%, #302c30b3 53%, transparent 84%); }
  .word { width: min(63%, 225px); }
  .tag { margin-bottom: 10px; }
  .load-tip { margin-top: 8px; font-size: 13px; line-height: 1.35; }
  .development-notice { gap: 9px; padding: 10px 12px; font-size: 12.5px; line-height: 1.36; }
  .notice-icon { font-size: 14px; }
}
@media (orientation: landscape) and (max-height: 510px) {
  .loading-layout { --gutter: 4vw; gap: 6px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .loading-main { width: min(45vw, 360px); }
  .word { width: min(100%, 38vh); }
  .tag { margin: 1px 0 12px; font-size: 13px; }
  #status { margin-bottom: 5px; font-size: 14px; }
  .rail { width: min(100%, 280px); height: 9px; }
  .load-tip { margin-top: 7px; font-size: 13px; line-height: 1.3; }
  .development-notice { gap: 12px; padding: 7px 13px; font-size: 12px; line-height: 1.3; }
  #retry { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #loader, .rail i { transition: none; }
}
#room-code{position:absolute;z-index:3;box-sizing:border-box;padding:0 .55em;background:transparent;border:0;color:#fff6df;font-family:inherit;font-weight:700;letter-spacing:.06em}
#room-code::placeholder{color:#f4e8d7;opacity:.9}
#room-code:focus-visible{outline:2px solid #ffc841;outline-offset:-2px}
#game-account { position: absolute; z-index: 2; right: max(12px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 9px; max-width: 55%; padding: 6px 10px; border-radius: 10px; background: #201d2ef0; color: #fff6df; font: 600 clamp(11px, 1.6vw, 14px)/1.3 system-ui, sans-serif; }
#game-account[hidden], #game-account button[hidden] { display: none; }
#account-status { overflow-wrap: anywhere; }
#account-login { border: 1px solid #ffdd76; border-radius: 7px; padding: 6px 9px; background: #ffdd76; color: #302426; font: inherit; cursor: pointer; }
#account-login:focus-visible { outline: 2px solid white; outline-offset: 2px; }
