/* ================================================================== *
 * game.css — 游戏页（game.html）
 * 默认窗口模式（16:9 居中），右上角按钮可切换全屏
 * ================================================================== */

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #0d1016;
  color: #f4f7fb;
  font: 16px/1.4 "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  overflow: hidden;
}

canvas {
  display: block;
}

[hidden] {
  display: none !important;
}

/* ------------------------------ 页面骨架 ------------------------------ */

.game-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ------------------------------ 顶部工具栏 ------------------------------ */

.game-topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(23, 30, 43, 0.96), rgba(13, 16, 22, 0.96));
  border-bottom: 1px solid rgba(94, 225, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #e7eefb;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.tb-btn:hover {
  background: rgba(94, 225, 255, 0.16);
  border-color: rgba(94, 225, 255, 0.55);
  transform: translateY(-1px);
}

.tb-btn:active {
  transform: translateY(0);
}

.tb-arrow {
  font-size: 15px;
  line-height: 1;
}

.tb-fs-icon {
  font-size: 13px;
  line-height: 1;
}

.tb-rank-icon {
  font-size: 14px;
  line-height: 1;
  color: #ffd479;
  text-shadow: 0 0 10px rgba(255, 179, 71, 0.7);
}

.tb-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #cfe3ff;
}

.tb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.85);
  animation: tb-pulse 2.2s ease-in-out infinite;
}

.tb-actions {
  display: flex;
  gap: 8px;
}

@keyframes tb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ------------------------------ 舞台 / 画布 ------------------------------ */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background:
    radial-gradient(circle at 50% 0%, #1c2436 0%, #10141d 46%, #080a0f 100%);
}

.unity-shell {
  position: relative;
  /* 窗口模式：16:9，宽度取「可用宽度 / 按高度换算的宽度」的较小值，最大 1280px */
  width: min(100%, calc((100vh - 80px) * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background:
    radial-gradient(circle at top, #293446 0%, #161c28 44%, #0a0d13 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.4);
}

#unity-canvas {
  width: 100%;
  height: 100%;
  background: #1b1f29;
}

/* ------------------------------ 全屏模式 ------------------------------ */

.game-page:fullscreen {
  background: #05070c;
}

.game-page:fullscreen .stage,
.game-page:-webkit-full-screen .stage {
  padding: 0;
  background: #05070c;
}

.game-page:fullscreen .unity-shell,
.game-page:-webkit-full-screen .unity-shell {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.is-fullscreen .game-topbar {
  /* 全屏时工具栏仍在，但更轻，避免抢戏 */
  background: rgba(8, 11, 16, 0.72);
}

/* ------------------------------ 加载遮罩 ------------------------------ */

.loading-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 9, 13, 0.55);
}

.loading-panel {
  width: min(560px, 100%);
  text-align: center;
}

.logo-wrap img {
  width: min(360px, 78vw);
  max-width: 100%;
  height: auto;
}

.progress-spinner-container {
  position: relative;
  width: min(420px, calc(100vw - 96px));
  margin: 24px auto 12px;
}

.spinner-left,
.spinner-right {
  position: absolute;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
}

.spinner-left {
  left: -42px;
}

.spinner-right {
  right: -42px;
}

.spinner-left img,
.spinner-right img {
  width: 100%;
  height: 100%;
  animation: spin 1s linear infinite;
}

#unity-progress-bar-empty {
  display: none;
  width: 100%;
  height: 20px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#unity-progress-bar-full {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fbc02d 0%, #ff7043 100%);
}

#status-text {
  margin: 10px 0 0;
  font-size: 14px;
  color: rgba(244, 247, 251, 0.82);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .game-topbar {
    height: 48px;
    padding: 0 8px;
  }

  .tb-btn-text {
    display: none;
  }

  .tb-btn {
    padding: 0 10px;
  }

  .stage {
    padding: 8px;
  }

  .unity-shell {
    width: min(100%, calc((100vh - 64px) * 16 / 9));
  }

  .progress-spinner-container {
    width: min(420px, calc(100vw - 72px));
  }

  .spinner-left {
    left: -32px;
  }

  .spinner-right {
    right: -32px;
  }
}

/* ------------------------------------------------------------------ *
 * 服务器存档 UI（server-save.js）
 * 顶部工具栏占用了页面顶端，这里把面板整体下移，避免互相遮挡
 * ------------------------------------------------------------------ */

.ra-save-chip {
  position: fixed;
  top: 64px; /* 原为 12px，给工具栏让位 */
  right: 12px;
  z-index: 33;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 76px);
  overflow: auto;
  padding: 12px 13px 10px;
  border-radius: 18px;
  background: radial-gradient(circle at top left, #0b1220, #020617, #020617);
  border: 1px solid rgba(94, 225, 255, 0.32);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.9);
}

.ra-save-chip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ra-save-head-title {
  font-size: 13px;
  font-weight: 600;
  color: #e5e7eb;
}

.ra-icon-button {
  border: 0;
  border-radius: 999px;
  padding: 4px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f7fb;
  cursor: pointer;
}

.ra-icon-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ra-save-note {
  margin: 0;
  color: #7f90a7;
  font-size: 11px;
  line-height: 1.4;
}

.ra-save-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ra-save-chip-text {
  min-width: 0;
}

.ra-save-title {
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ra-save-sub {
  margin-top: 2px;
  font-size: 10px;
  color: #9ca3af;
}

.ra-save-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b7280;
}

.ra-save-dot.ok {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.ra-save-dot.pending {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
}

.ra-save-dot.error {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.7);
}

.ra-save-dot.offline {
  background: #6b7280;
}

.ra-save-chip-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.ra-mini-button {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  background: #020617;
  color: #f4f7fb;
  border: 1px solid rgba(75, 85, 99, 0.9);
  cursor: pointer;
}

.ra-mini-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ra-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.82);
}

.ra-modal {
  width: min(380px, 100%);
  padding: 18px;
  border-radius: 18px;
  background: #0a1220;
  color: #f4f7fb;
  border: 1px solid rgba(94, 225, 255, 0.22);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.ra-modal h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.ra-modal p {
  margin: 0 0 14px;
  color: #c9d7e7;
  font-size: 12px;
  line-height: 1.5;
}

.ra-form {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.ra-label {
  font-size: 11px;
  color: #9ca3af;
}

.ra-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background: #020617;
  color: #f4f7fb;
  font: inherit;
  font-size: 13px;
  margin-bottom: 6px;
}

.ra-input:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.6);
}

.ra-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

.ra-error {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
  font-size: 12px;
  line-height: 1.45;
}

.ra-modal-actions {
  display: grid;
  gap: 8px;
}

.ra-button {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #020617;
  color: #f4f7fb;
  border: 1px solid rgba(75, 85, 99, 0.9);
}

.ra-button.primary {
  background: #ffffff;
  color: #111827;
  border-color: #ffffff;
}

.ra-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 70;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(8, 12, 20, 0.97);
  color: #f4f7fb;
  border: 1px solid rgba(94, 225, 255, 0.28);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  font-size: 13px;
}

@media (max-width: 760px) {
  .ra-save-chip {
    left: 10px;
    right: 10px;
    top: 58px;
    bottom: auto;
    width: auto;
    max-height: calc(100vh - 70px);
  }
}
