* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02061a; color: #fff;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif; touch-action: none;
  -webkit-user-select: none; user-select: none; }
#game { position: fixed; inset: 0; display: block; }
button { font-family: inherit; cursor: pointer; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #4fc3f7 0%, #0277bd 60%, #0d2b5e 100%); overflow: auto; padding: 16px; z-index: 20; }
.panel { background: rgba(255,255,255,0.94); color: #123; border-radius: 24px; padding: 24px 22px; width: min(520px, 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; }
.panel h1 { margin: 0 0 6px; font-size: clamp(24px, 6vw, 34px); color: #0b5aa2; }
.panel h2 { margin: 8px 0; color: #0b5aa2; }
.sub { color: #456; margin: 6px 0 16px; font-size: 15px; line-height: 1.5; }
.lbl { display: block; text-align: left; font-weight: 700; margin: 12px 0 6px; color: #234; }
#name { width: 100%; font-size: 20px; padding: 12px 14px; border: 3px solid #90caf9; border-radius: 14px; outline: none; }
#name:focus { border-color: #0288d1; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { font-size: 32px; padding: 8px 0; border: 3px solid #e0e0e0; border-radius: 14px; background: #fff; line-height: 1.2; }
.avatars button.sel { border-color: #ff9800; background: #fff3e0; transform: scale(1.08); }
.big { font-size: 18px; padding: 12px 20px; border-radius: 16px; border: 0; background: #e3f2fd; color: #0b5aa2; font-weight: 700;
  margin-top: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.big:active { transform: translateY(2px); box-shadow: none; }
.big.primary { background: #ff9800; color: #fff; }
#board-canvas { width: 100%; max-width: 360px; height: auto; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#hud-top { position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0; display: flex; justify-content: space-between;
  align-items: flex-start; padding: 10px; gap: 8px; pointer-events: none; }
#hud-top > * { pointer-events: auto; }
#hud-player { background: rgba(0,0,0,.45); border-radius: 30px; padding: 6px 14px 6px 8px; display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; }
#hud-avatar { font-size: 26px; }
#hud-zone { background: rgba(0,0,0,.45); border-radius: 16px; padding: 6px 14px; text-align: center; }
#hud-zone-name { font-weight: 800; font-size: 17px; letter-spacing: 2px; }
#hud-depth { font-size: 13px; opacity: .9; font-variant-numeric: tabular-nums; }
#hud-btns { display: flex; gap: 6px; }
.hud-btn { background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 14px; font-size: 22px; padding: 6px 10px; }
.hud-btn span { font-size: 13px; margin-left: 2px; font-weight: 700; }
#zone-banner { position: absolute; top: 24%; left: 50%; transform: translate(-50%, 0); background: rgba(0,0,0,.55);
  padding: 14px 26px; border-radius: 20px; font-size: clamp(22px, 5vw, 34px); font-weight: 800; letter-spacing: 3px;
  animation: banner 3.2s ease forwards; text-align: center; pointer-events: none !important; }
#zone-banner small { display: block; font-size: 14px; letter-spacing: 0; font-weight: 500; margin-top: 6px; opacity: .9; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 20px);} 12% { opacity: 1; transform: translate(-50%, 0);} 80% { opacity: 1;} 100% { opacity: 0;} }
#hint { position: absolute; bottom: 24%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.5); padding: 8px 16px;
  border-radius: 14px; font-size: 15px; pointer-events: none !important; white-space: nowrap; }
#dpad { position: absolute; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0)); display: grid;
  grid-template-areas: ". u ." "l . r" ". d ."; grid-template-columns: 56px 56px 56px; grid-template-rows: 56px 56px 56px; gap: 4px; }
.dbtn { border: 0; border-radius: 16px; background: rgba(255,255,255,.28); color: #fff; font-size: 24px; touch-action: none;
  backdrop-filter: blur(4px); }
.dbtn.on, .dbtn:active { background: rgba(255,193,7,.75); }
#btn-photo { position: absolute; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom, 0)); width: 92px; height: 92px; border-radius: 50%;
  border: 5px solid #fff; background: #ff9800; font-size: 40px; box-shadow: 0 6px 20px rgba(0,0,0,.4); touch-action: none; }
#btn-photo:active { transform: scale(.94); }
#viewfinder { position: absolute; left: 20%; top: 20%; width: 60%; height: 60%; border: 2px dashed rgba(255,255,255,.35);
  border-radius: 12px; pointer-events: none !important; }
#viewfinder::before { content: ""; position: absolute; inset: -2px; border: 14px solid transparent; border-image: none; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none !important; }
#flash.on { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
@media (min-width: 900px) { #dpad { grid-template-columns: 64px 64px 64px; grid-template-rows: 64px 64px 64px; } }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,10,30,.7); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 12px; }
.modal-box { position: relative; background: #fff; color: #123; border-radius: 22px; padding: 18px; width: min(460px, 100%);
  max-height: 94vh; overflow: auto; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.close { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #eee; font-size: 18px; z-index: 1; }
.card-photo { border-radius: 16px; overflow: hidden; background: #0d2b5e; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.card-photo img { width: 100%; height: 100%; object-fit: contain; }
.zname { font-size: clamp(30px, 8vw, 40px); font-weight: 800; margin: 12px 0 4px; color: #0b5aa2; display: flex; justify-content: center; flex-wrap: wrap; }
.ch { display: inline-flex; align-items: center; margin: 0 .12em; }
.zy { position: relative; writing-mode: vertical-rl; text-orientation: upright; font-size: .36em; line-height: 1; margin-left: .1em;
  color: #e65100; font-weight: 700; letter-spacing: -.08em; padding-right: .2em; }
.zy .tn { position: absolute; right: -.75em; bottom: .05em; font-style: normal; }
.zy .lt { font-style: normal; }
.tag { display: inline-block; background: #e3f2fd; color: #0b5aa2; border-radius: 20px; padding: 3px 12px; font-size: 14px; font-weight: 700; }
.row { display: flex; gap: 8px; justify-content: center; }
.row .big { margin-top: 12px; flex: 1; }
.fact { font-size: 18px; line-height: 1.6; text-align: left; background: #fff8e1; border-radius: 14px; padding: 12px 14px; margin: 14px 0 8px; }
.credit { font-size: 11px; color: #789; line-height: 1.4; margin: 6px 0 0; }
.credit a { color: #0b5aa2; }
#photo-img { width: 100%; border-radius: 14px; border: 4px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); background: #000; }
#photo-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.found { display: flex; align-items: center; gap: 10px; background: #f3f7fb; border-radius: 14px; padding: 8px 10px; text-align: left; }
.found img { width: 64px; height: 48px; object-fit: cover; border-radius: 10px; background: #000; }
.found .zname { font-size: 24px; margin: 0; flex: 1; justify-content: flex-start; }
.found .new { background: #ff9800; color: #fff; border-radius: 20px; padding: 3px 8px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.found .sp { border: 0; border-radius: 50%; width: 42px; height: 42px; font-size: 20px; background: #e3f2fd; }
.empty { color: #567; font-size: 16px; padding: 14px; }

/* album */
#screen-album { display: block; overflow: auto; padding: 0; background: linear-gradient(180deg, #0277bd, #02061a); touch-action: pan-y; }
.album-head { position: sticky; top: 0; background: rgba(2,6,26,.85); backdrop-filter: blur(6px); padding: 10px 14px; display: flex; align-items: center; gap: 12px; z-index: 2;
  padding-top: calc(10px + env(safe-area-inset-top, 0)); }
.album-head h2 { margin: 0; font-size: 20px; }
.album-head .big { margin: 0; padding: 8px 14px; font-size: 15px; }
.zone-sec { padding: 10px 14px; }
.zone-sec h3 { margin: 8px 0; font-size: 20px; display: flex; align-items: baseline; gap: 10px; }
.zone-sec h3 small { font-size: 13px; opacity: .8; font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.cell { background: rgba(255,255,255,.1); border-radius: 16px; padding: 8px; text-align: center; cursor: pointer; border: 2px solid transparent; }
.cell.on { background: rgba(255,255,255,.92); color: #123; border-color: #ffb300; }
.cell .thumb { width: 100%; aspect-ratio: 4/3; border-radius: 12px; background: #06122e; object-fit: cover; display: block; }
.cell.off .thumb { filter: brightness(.12) blur(1px); }
.cell .nm { font-weight: 800; margin-top: 6px; font-size: 16px; }
.cell.off .nm { opacity: .6; }
#album-photos-wrap { padding: 10px 14px; }
#album-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
#album-photos img { width: 100%; border-radius: 10px; border: 3px solid #fff; display: block; }

/* 手機窄螢幕調整 */
#hud-name, #hud-zone-name, #hud-depth { white-space: nowrap; }
#hud-zone { flex-shrink: 0; }
#hint { white-space: normal; max-width: 88vw; text-align: center; line-height: 1.4; }
@media (max-width: 600px) {
  #hud-top { padding: 6px; gap: 4px; }
  #hud-name { display: none; }
  #hud-player { padding: 4px 8px; }
  #hud-avatar { font-size: 22px; }
  #hud-zone { padding: 4px 10px; }
  #hud-zone-name { font-size: 14px; letter-spacing: 1px; }
  #hud-depth { font-size: 11px; }
  .hud-btn { font-size: 17px; padding: 4px 7px; border-radius: 10px; }
  .hud-btn span { font-size: 11px; }
  #zone-banner { font-size: 20px; padding: 10px 16px; width: 86vw; }
  #zone-banner small { font-size: 12px; }
}
