:root {
  --ink: #16324a;
  --glass: rgba(18, 32, 46, 0.52);
  --line: rgba(255, 255, 255, 0.14);
  --sky: #9fd4e8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#game {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8ec8dc;
  font-family: "Noto Sans SC", sans-serif;
}

canvas {
  display: block;
}

#gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 70% 20%, rgba(255, 255, 255, 0.45), transparent 55%),
    linear-gradient(180deg, #b9e3f2 0%, #8ec8dc 45%, #dfeaf0 100%);
}

.gate-card {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 36px 32px 28px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(40, 90, 120, 0.18);
  color: var(--ink);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
}

.auth-tabs button {
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #5b7c8f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-tabs button.on {
  background: #16324a;
  color: #fff;
}

.auth-welcome {
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

#auth-form label + label {
  margin-top: 12px;
}

.gate-error,
.gate-success {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.gate-error {
  color: #b42318;
}

.gate-success {
  color: #1f7a4d;
}

.gate-text-btn {
  width: 100%;
  margin-top: 10px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #5b7c8f;
  font: inherit;
  cursor: pointer;
}

.gate-kicker {
  letter-spacing: 0.28em;
  font-size: 11px;
  color: #4f7f98;
}

.gate-card h1 {
  font-family: Fraunces, serif;
  font-size: 64px;
  line-height: 1;
  margin: 6px 0 10px;
}

.gate-sub {
  color: #4d6d80;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 22px;
}

.gate-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: #5b7c8f;
}

.gate-card input {
  height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.swatch-label {
  margin: 16px 0 8px;
  font-size: 12px;
  color: #5b7c8f;
}

.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.swatches button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}

.swatches button.on {
  border-color: var(--ink);
}

#enter-btn {
  width: 100%;
  margin-top: 22px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: #16324a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#enter-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.me-name,
.hud-signout {
  font-size: 13px;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  color: #fff;
}

.hud-signout {
  cursor: pointer;
  font: inherit;
}

.gate-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: #6b8ea0;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  color: #fff;
}

#hud > * {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

.topbar {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  font-family: Fraunces, serif;
  font-size: 22px;
  padding: 6px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}

#online-count {
  font-size: 13px;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}

.top-right {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.view-toggle {
  display: flex;
  padding: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(12px);
}

.view-toggle button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.view-toggle button.on {
  background: rgba(255, 255, 255, 0.92);
  color: #16324a;
}

.floor-badge {
  font-family: Fraunces, serif;
  font-size: 28px;
  padding: 4px 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
}

.directory {
  position: absolute;
  top: 78px;
  right: 20px;
  width: 230px;
  padding: 16px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
}

.directory h2 {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  margin-bottom: 10px;
}

.directory li {
  list-style: none;
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
}

.who strong {
  display: block;
  font-weight: 700;
}

.who span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.minimap-wrap {
  position: absolute;
  top: 78px;
  left: 20px;
  width: 180px;
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
}

#minimap-title {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.minimap {
  position: relative;
  height: 128px;
  border-radius: 12px;
  overflow: hidden;
  background: #d7e6ee;
}

.mm-zone {
  position: absolute;
  font-size: 9px;
  color: #3d5d70;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.2;
}

.mm-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.chat-dock {
  position: absolute;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 48px));
}

.chat-log:empty {
  display: none;
}

.chat-log {
  max-height: 132px;
  overflow: auto;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(16px);
}

.chat-line {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.45;
  padding: 2px 0;
}

.chat-line span {
  color: rgba(255, 255, 255, 0.9);
  word-break: break-all;
}

.chat-row {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  background: rgba(255, 255, 255, 0.92);
  color: #16324a;
  outline: none;
}

#mic-btn {
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.88);
  color: #16324a;
  cursor: pointer;
}

#mic-btn.on {
  background: #1f8f62;
  color: #fff;
}

.speech-bubble {
  max-width: 220px;
  padding: 8px 12px 10px;
  background: #fff;
  color: #1a2a38;
  border-radius: 14px 14px 14px 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(16, 32, 48, 0.2);
  transform: translate(-50%, -120%);
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.speech-bubble.hidden {
  display: none;
}

.self-bubble {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  max-width: min(360px, 70vw);
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a2a38;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  pointer-events: none;
}

.place-card {
  position: absolute;
  left: 20px;
  bottom: 28px;
  width: min(320px, calc(100vw - 40px));
  padding: 16px 18px 18px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(16px);
}

#place-floor {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.62);
}

#place-name {
  font-family: Fraunces, serif;
  font-size: 34px;
  font-weight: 560;
  line-height: 1.1;
  margin: 2px 0 6px;
}

#place-hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.45;
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.lift-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  padding: 18px;
  background: rgba(16, 28, 40, 0.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(16px);
  text-align: center;
}

.lift-modal p {
  margin-bottom: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.lift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lift-grid button,
#lift-cancel {
  height: 44px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
}

.lift-grid button {
  background: #e8f6fb;
  color: #16324a;
  font-weight: 700;
}

.lift-grid button:disabled {
  opacity: 0.35;
}

#lift-cancel {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
}

.travel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 22, 34, 0.42);
  pointer-events: none;
  text-align: center;
}

.travel strong {
  font-family: Fraunces, serif;
  font-size: 88px;
  line-height: 1;
}

.travel span {
  color: rgba(255, 255, 255, 0.7);
}

.dock {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.dock span {
  padding: 7px 10px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  backdrop-filter: blur(12px);
}

@media (max-width: 720px) {
  .directory,
  .minimap-wrap,
  .dock {
    display: none;
  }
}
