@font-face {
  font-family: "Fusion Pixel";
  src: url("/fonts/fusion-pixel-12.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0c1016;
  --panel: #141922;
  --line: #31384a;
  --text: #e7ecf5;
  --dim: #93a0b5;
  --warm: #f0b45a;
  --ink: #1c140c;
  color: var(--text);
  background: var(--bg);
  font-family: "Fusion Pixel", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
  font-smooth: never;
  -webkit-font-smoothing: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button, input { font: inherit; color: inherit; }
button {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 8px 10px;
  min-height: 32px;
  cursor: pointer;
}
button:hover, button:focus-visible { border-color: var(--warm); outline: none; }
button.on { background: var(--warm); color: var(--ink); border-color: var(--warm); }
.dim { color: var(--dim); }

/* 画布铺满屏幕时会超出视口，放在固定容器里裁掉，避免手机把布局宽度撑大 */
#stage { position: fixed; inset: 0; overflow: hidden; }
#scene {
  position: absolute;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  background: #070b12;
}

#gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(8, 10, 16, 0.28);
  border: 0;
  width: 100%;
}
#gate .mark { font-size: 36px; letter-spacing: 4px; }
#gate .playbox {
  background: var(--warm);
  color: var(--ink);
  padding: 12px 28px;
  border: 2px solid #ffd89a;
  font-size: 24px;
}
#gate .hint { color: var(--text); background: var(--panel); padding: 6px 8px; border: 2px solid var(--line); }

#top, #dock, .edge, .sheet, .pop { z-index: 3; }
#top {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  pointer-events: none;
}
#top button, .top-actions { pointer-events: auto; }
#cname { font-size: 24px; line-height: 1.2; text-shadow: 2px 2px 0 #070b12; }
#cmeta { margin-top: 4px; color: var(--text); background: var(--panel); display: inline-block; padding: 4px 6px; border: 2px solid var(--line); font-size: 14px; }
#fcast { margin-top: 4px; color: var(--dim); background: var(--panel); display: inline-block; padding: 2px 6px; border: 2px solid var(--line); font-size: 12px; }
#fcast:empty { display: none; }
#fcast a { color: var(--warm); }
.top-actions { display: flex; gap: 6px; }

.edge {
  position: absolute;
  top: 42%;
  width: 36px;
  height: 48px;
  font-size: 24px;
  background: rgba(20, 25, 34, 0.88);
}
.edge.right { right: 8px; }
#prev-city { left: 8px; }

#dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(12, 16, 22, 0.92);
  border-top: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.track { flex: 1; min-width: 140px; }
#title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#time { color: var(--dim); }
input[type="range"] {
  width: 100%;
  accent-color: var(--warm);
  height: 16px;
}
.vol { display: flex; align-items: center; gap: 6px; color: var(--dim); }
.vol input { width: 88px; }
.seg { display: flex; }
select {
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--line);
  padding: 6px 8px;
  min-height: 32px;
  font: inherit;
  cursor: pointer;
}
select:focus-visible { border-color: var(--warm); outline: none; }
.seg button { margin: 0; }
.seg button + button { border-left: 0; }

#eq { image-rendering: pixelated; background: #0c1016; border: 2px solid var(--line); flex: none; }

.sheet, .pop {
  position: absolute;
  inset: 0;
  background: #0c1016;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.sheet[hidden], .pop[hidden], #gate[hidden] { display: none; }
.sheet-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 2px solid var(--line);
}
.sheet-bar b { font-size: 16px; }
.sheet-bar .dim { flex: 1; }
#grid, #tracks { overflow: auto; padding: 10px; flex: 1 1 auto; min-height: 0; }
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  text-align: left;
  background: #10151e;
}
.card canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #070b12;
}
.card span { padding: 6px 8px 0; }
.card .en { color: var(--dim); padding-bottom: 8px; }
.card.on { background: #10151e; color: var(--text); border-color: var(--warm); }

.track-btn { display: flex; justify-content: space-between; width: 100%; margin-bottom: 6px; }
.track-btn.on { background: #1c2433; color: var(--warm); border-color: var(--warm); }

.pop { padding: 12px; gap: 8px; }
#clockline { font-size: 16px; }
#phone-hint { max-width: 520px; }

body.ui-off #top,
body.ui-off #dock,
body.ui-off .edge { opacity: 0; pointer-events: none; }

@media (max-width: 720px) {
  #cmeta { max-width: 70vw; }
  .edge { top: auto; bottom: 128px; }
  #title { max-width: 46vw; }
}

@media (max-height: 520px) {
  #cname { font-size: 16px; }
  #dock { gap: 4px; padding-top: 4px; }
  button { min-height: 28px; padding: 4px 8px; }
}

/* 顶部信息：文字块占满可用宽度，按钮不换行 */
#cmeta, #fcast { display: block; width: fit-content; max-width: 100%; box-sizing: border-box; }
#top button, .top-actions select { white-space: nowrap; }
.top-actions select { max-width: 150px; }
/* 手机：语言和两个按钮竖排在右上角，文字块在左边占满 */
@media (max-width: 720px) {
  .top-actions { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; flex-direction: column; align-items: flex-end; gap: 4px; }
  .top-actions select { max-width: 96px; }
  #top > div:first-child { padding-right: 110px; min-width: 0; }
  #cmeta, #fcast { width: 100%; }
}
/* 底部小动物的控件 */
.pet-ctl { display: flex; align-items: center; gap: 6px; color: var(--dim); }
#pet-size { width: 96px; }

/* ===== 自适应：手机竖屏（9:16）===== */
@media (orientation: portrait) and (max-width: 600px) {
  #top { left: 10px; right: 10px; top: calc(8px + env(safe-area-inset-top)); }
  #cname { font-size: 20px; }
  #cmeta { font-size: 12px; }
  #fcast { font-size: 10.5px; }
  .top-actions { top: calc(8px + env(safe-area-inset-top)); }
  #dock { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  #dock .row { gap: 5px; flex-wrap: wrap; }
  #dock button, #dock select { font-size: 12px; padding: 5px 7px; min-height: 30px; }
  #dock .track { flex: 1 1 140px; min-width: 0; }
  #eq { display: none; }
  .vol input, .pet-ctl input[type="range"] { width: 72px; }
  #pet-size { width: 72px; }
  .edge { top: 36%; width: 30px; height: 40px; font-size: 20px; }
  .top-actions select { max-width: 96px; }
}

/* ===== 自适应：手机横屏（16:9，矮）===== */
@media (orientation: landscape) and (max-height: 500px) {
  #top { top: calc(6px + env(safe-area-inset-top)); }
  #cname { font-size: 15px; }
  #cmeta { font-size: 11px; padding: 2px 5px; }
  #fcast { font-size: 10px; padding: 1px 5px; }
  #dock { padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); gap: 4px; }
  #dock .row { gap: 4px; }
  #dock button, #dock select { font-size: 11px; padding: 3px 6px; min-height: 26px; }
  #eq { display: none; }
  .track { min-width: 120px; }
  .top-actions select { max-width: 110px; }
  .edge { width: 28px; height: 36px; font-size: 18px; }
}

/* ===== 更友好的按钮：圆角、柔和、按下有回弹（画面仍是像素）===== */
button, select { border-radius: 12px; }
button {
  background: #1a2130;
  border-color: #2c3548;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}
button:hover, button:focus-visible { border-color: #f0b45a; }
button:active { transform: scale(0.97); }
button.on {
  background: #f0b45a;
  color: #1c140c;
  border-color: #ffd89a;
  box-shadow: 0 2px 8px rgba(240, 180, 90, 0.35);
}
button.round {
  min-width: 62px; height: 42px; min-height: 42px; padding: 0 10px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
select { background: #1a2130; border-color: #2c3548; border-radius: 12px; }
.seg { gap: 4px; }
.seg button, .seg button + button { border-left: 2px solid #2c3548; border-radius: 999px; }
.seg button:first-child { border-left: 2px solid #2c3548; }
.seg button.on { border-left-color: #ffd89a; }
#cmeta, #fcast { border: none; border-radius: 12px; background: rgba(14, 18, 26, 0.82); }
.edge { border-radius: 50%; }

/* 底栏：上边圆角，像一张托起的卡片 */
#dock {
  border-top: none;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(180deg, rgba(14, 18, 26, 0.92), rgba(10, 13, 19, 0.97));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
}
/* 二级面板：点「更多」展开，分组排列，超出时在里面滚动 */
#drawer { display: flex; flex-direction: column; gap: 10px; max-height: 48vh; overflow-y: auto; padding-top: 4px; }
#drawer[hidden] { display: none; }
.grp { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.03); }
.grp-title { font-size: 11px; color: var(--dim); letter-spacing: 0.04em; }
.grp .row { gap: 6px; }

/* ===== 手机：城市列表像苹果天气，一行一座城，左边名字，右边小缩略图 ===== */
@media (max-width: 720px), (max-height: 500px) {
  #grid { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
  .card {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 104px 1fr;
    column-gap: 12px;
    align-items: center;
    padding: 8px;
    border-radius: 14px;
    background: #141a24;
    border: 1px solid #232b3b;
    width: 100%;
  }
  .card canvas { grid-column: 1; grid-row: 1 / span 2; width: 104px; height: 58px; border-radius: 8px; }
  .card > span:first-of-type { grid-column: 2; grid-row: 1; padding: 0; font-size: 16px; }
  .card .en { grid-column: 2; grid-row: 2; padding: 0 0 0; font-size: 12px; color: var(--dim); }
  .card.on { border-color: #f0b45a; background: #1c2230; }
}

/* 桌面和宽屏：二级面板的分组横向排开，少占高度 */
@media (min-width: 721px) and (min-height: 501px) {
  #drawer { flex-direction: row; flex-wrap: wrap; align-items: stretch; }
  #drawer .grp { flex: 1 1 280px; }
}

/* ===== 精细化的界面：统一的颜色和质感（参考但不照搬，保持我们的像素风）===== */
:root {
  --glass: rgba(12, 16, 22, 0.74);
  --glass-strong: rgba(12, 16, 22, 0.9);
  --glass-line: rgba(255, 255, 255, 0.08);
  --accent-2: #ffd89a;
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.38);
}

/* 画面边缘的暗角，让中间的场景更有层次（不挡操作） */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 42%, transparent 58%, rgba(4, 6, 10, 0.42) 100%);
  pointer-events: none;
}

/* 顶部信息：标题更醒目，信息块做成磨砂玻璃 */
#cname { text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 18px rgba(0, 0, 0, 0.25); letter-spacing: 0.02em; }
#cmeta, #fcast {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 10px;
}
#cmeta { box-shadow: var(--shadow-soft); }
#fcast { color: #aab4c6; }

/* 底栏：磨砂玻璃卡片，顶边一条细光 */
#dock {
  background: linear-gradient(180deg, rgba(14, 18, 26, 0.80), var(--glass-strong));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--glass-line);
}

/* 按钮：轻微渐变和高光，按下有回弹 */
button {
  background: linear-gradient(180deg, #232c3e 0%, #1a2130 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 6px rgba(0, 0, 0, 0.3);
  color: #e6ecf7;
  letter-spacing: 0.01em;
}
button:hover { background: linear-gradient(180deg, #283248 0%, #1e2638 100%); }
button.on {
  background: linear-gradient(180deg, #ffc978 0%, #f0a94a 100%);
  color: #1c140c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 10px rgba(240, 180, 90, 0.35);
}
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.edge { background: var(--glass-strong); border: 1px solid var(--glass-line); box-shadow: var(--shadow-soft); }

/* 城市网格（桌面）：卡片有轻微上浮和阴影 */
.card {
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  border-radius: 12px;
  overflow: hidden;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.card canvas { border-radius: 0; }

/* 细滚动条 */
#drawer, #grid, #tracks { scrollbar-width: thin; scrollbar-color: #2c3548 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2c3548; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* 文字层级：次要信息更淡、更小 */
.dim, .grp-title { color: #8e9ab0; }

/* 城市标题：名字下面一句，像一张明信片的小字 */
#mood { font-size: 13px; color: #c9d2e2; margin-top: 2px; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); letter-spacing: 0.02em; }
/* 洲的标签 */
#regions { display: flex; gap: 6px; overflow-x: auto; padding: 10px 10px 0; scrollbar-width: none; }
#regions::-webkit-scrollbar { display: none; }
.region-btn { flex: none; border-radius: 999px; padding: 5px 12px; min-height: 30px; font-size: 12px; }
.region-btn.on { background: linear-gradient(180deg, #ffc978 0%, #f0a94a 100%); color: #1c140c; border-color: #ffd89a; }

/* 左右切城的圆形按钮：宽高用同一个变量，永远是正圆，不随屏幕压扁 */
:root { --edge-size: clamp(30px, 7vmin, 46px); }
.edge {
  width: var(--edge-size);
  height: var(--edge-size);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  padding: 0;
  font-size: calc(var(--edge-size) * 0.5);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 城市列表：默认完整显示，按洲分组，小标题跟着滚动 ===== */
#grid { position: relative; display: block; }
.region-sec { margin-bottom: 14px; }
.region-title {
  position: sticky; top: 0; z-index: 2;
  margin: 0; padding: 8px 4px 6px;
  font-size: 12px; font-weight: normal; letter-spacing: 0.08em;
  color: var(--dim); background: rgba(12, 16, 22, 0.94);
}
.region-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
@media (max-width: 720px), (max-height: 500px) {
  .region-cards { display: flex; flex-direction: column; gap: 8px; }
}
/* 洲的标签栏不被压缩（之前在竖向布局里会被压成细条，文字看不见） */
#regions { flex: none; }

/* 页脚的小链接：关于与隐私政策 */
.legal-links { margin: 14px 0 0; font-size: 12px; text-align: center; opacity: .75; }
.legal-links a { color: inherit; }
