/* 【遊戲大廳】配色沿用遊戲王國共用的「白黑灰」：大面積白色，不分淺色／深色。 */
:root {
  --bg: #FFFFFF;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --box: #F0F0F0;
  --soft: #EBEBEB;
  --accent: #3A3A3A;
  --accent-text: #FFFFFF;
  --danger: #D8432A;
  --ok: #2a7d3f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  -webkit-text-size-adjust: 100%;
}
main { max-width: 560px; margin: 0 auto; padding: 20px 0 40px; }
button {
  -webkit-appearance: none; appearance: none; border: 0; cursor: pointer; font: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 字標：Your（上一行、對齊 G）＋ GameKingdom ===== */
.wm { display: inline-flex; flex-direction: column; align-items: flex-start; margin: 0; line-height: 1; color: #111;
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-weight: 800; letter-spacing: -.5px; }
.wm .your { font-size: .5em; margin: 0 0 .12em .06em; letter-spacing: 0; }
/* StudioNum868：只在進場動畫出現，靠右、最後的 8 對齊 GameKingdom 最後的 m（字標是 flex 欄，靠右即對齊 m 右緣） */
.wm .studio { display: none; }
#intro .wm .studio { display: block; align-self: flex-end; font-size: .34em; margin: .9em 0 0; letter-spacing: 0; white-space: nowrap; }
.wm .gk { display: block; white-space: nowrap; }
.wm .gk i { display: inline-block; font-style: normal; }

/* 固定區（字標＋分類列＋分隔線）：往下滑時黏在畫面最上方，白底蓋住從底下捲過的遊戲格。
   往上多墊「main 的上邊距 20px＋瀏海安全區」，這樣狀態列那一段也是白底，不會透出捲動中的內容 */
.head { position: sticky; top: 0; z-index: 10; background: var(--bg);
  margin: calc(-20px - env(safe-area-inset-top)) 0 28px; padding: calc(20px + env(safe-area-inset-top)) 0 0; }

/* 頁首 */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
.top .wm { font-size: 30px; }

/* ===== 進場動畫 ===== */
#intro { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; align-items: center; justify-content: center; }
#intro .wm.big { font-size: min(10.4vw, 60px); }   /* 字標寬度約佔畫面 3/4，左右各留約 1/8 */
/* 直向（手機直拿）：字標比正中間高一點，中心約在畫面高度 40% 的位置（下方墊 20% 高度把它往上推） */
@media (orientation: portrait) { #intro { padding-bottom: 20vh; } }
.no-intro #intro { display: none; }
/* 逐字彈跳落下：每個字比前一個晚 55 毫秒 */
#intro .gk i { opacity: 0; animation: gk-drop .52s cubic-bezier(.3, .7, .4, 1) both; }
#intro .gk i:nth-child(2) { animation-delay: 55ms; }
#intro .gk i:nth-child(3) { animation-delay: 110ms; }
#intro .gk i:nth-child(4) { animation-delay: 165ms; }
#intro .gk i:nth-child(5) { animation-delay: 220ms; }
#intro .gk i:nth-child(6) { animation-delay: 275ms; }
#intro .gk i:nth-child(7) { animation-delay: 330ms; }
#intro .gk i:nth-child(8) { animation-delay: 385ms; }
#intro .gk i:nth-child(9) { animation-delay: 440ms; }
#intro .gk i:nth-child(10) { animation-delay: 495ms; }
#intro .gk i:nth-child(11) { animation-delay: 550ms; }
@keyframes gk-drop {
  0%   { opacity: 0; transform: translateY(-1.6em); }
  50%  { opacity: 1; transform: translateY(0); }
  68%  { transform: translateY(-.34em); }
  84%  { transform: translateY(0); }
  92%  { transform: translateY(-.1em); }
  100% { opacity: 1; transform: translateY(0); }
}
/* Your：從畫面左邊外面快速拉進來，略微衝過頭再回位 */
#intro .your, #intro .studio { opacity: 0; animation: gk-your .3s cubic-bezier(.2, .9, .3, 1.25) both; animation-delay: 1.12s; }
@keyframes gk-your {
  0%   { opacity: 1; transform: translateX(-110vw); }
  100% { opacity: 1; transform: translateX(0); }
}
/* 過場：字標縮小飛到頁首的位置（位移與縮放由 app.js 算），白幕同時淡掉，大廳內容由下往上依序浮現 */
#intro { transition: background-color .6s ease; }
#intro .wm.big { transform-origin: 0 0; transition: transform .65s cubic-bezier(.65, 0, .2, 1); will-change: transform; }
#intro.fly { background-color: rgba(255, 255, 255, 0); pointer-events: none; }
#intro.fly .gk i, #intro.fly .your { animation: none; opacity: 1; }
#intro.fly .studio { animation: gk-fadeout .25s ease both; }
@keyframes gk-fadeout { from { opacity: 1; transform: none; } to { opacity: 0; transform: none; } }   /* 過場時淡出，大廳版號上方的同名小字隨內容浮現 */
.intro-on .top .wm { visibility: hidden; }            /* 動畫期間頁首字標先藏起來，飛到定位後再換手 */
.intro-on main > :not(.head), .intro-on .filters { opacity: 0; }
.enter main > :not(.head), .enter .filters { animation: gk-rise .5s ease both; }
.enter .filters { animation-delay: .1s; }
.enter main > section { animation-delay: .18s; }
.enter .tile { animation: gk-rise .45s ease both; }
.enter .tile:nth-child(1) { animation-delay: 250ms; }
.enter .tile:nth-child(2) { animation-delay: 300ms; }
.enter .tile:nth-child(3) { animation-delay: 350ms; }
.enter .tile:nth-child(4) { animation-delay: 400ms; }
.enter .tile:nth-child(5) { animation-delay: 450ms; }
.enter .tile:nth-child(6) { animation-delay: 500ms; }
.enter .tile:nth-child(7) { animation-delay: 550ms; }
.enter .tile:nth-child(8) { animation-delay: 600ms; }
.enter .tile:nth-child(9) { animation-delay: 650ms; }
.enter .tile:nth-child(10) { animation-delay: 700ms; }
.enter .tile:nth-child(11) { animation-delay: 750ms; }
.enter .tile:nth-child(12) { animation-delay: 800ms; }
@keyframes gk-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
/* 關閉動態效果時：只淡出 */
#intro.out { opacity: 0; transition: opacity .3s ease; pointer-events: none; }
/* 使用者關閉動態效果時：不彈跳，直接顯示 */
@media (prefers-reduced-motion: reduce) {
  #intro .gk i, #intro .your, #intro .studio { animation: none; opacity: 1; }
}

/* ===== 分類列（小圖示）＋人數（圖示，點了展開選單） ===== */
/* 分類列下方一條分隔線，線的上下各空一列（28px） */
.filters { display: flex; align-items: flex-start; gap: 16px; margin: 0; padding: 0 0 28px; border-bottom: 1px solid #e2e2e2; }
.cats { flex: 1; display: flex; gap: 8px; min-width: 0; }   /* 五個分類平均分配寬度（長方形），排到人數按鈕前 */
.cats .cat { flex: 1; min-width: 0; }
.cats .cat .ci { width: 100%; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.2; touch-action: manipulation; }
@media (min-width: 520px) { .cat { font-size: 15px; gap: 6px; } }
.cat .ci { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 14px; background: var(--box); color: var(--text); transition: transform .12s; }
.cat:active .ci { transform: scale(.94); }
.cat.on { color: var(--text); }
.cat.on .ci { background: var(--accent); color: var(--accent-text); }
.pp { position: relative; flex: none; }
/* 人數按鈕：白色圓底＋灰色外框（和分類的淺灰方塊區分）；有選條件時外框變黑 */
.pp .cat .ci { border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1.5px #c9c9c9; }
.pp .cat.on .ci { background: #fff; color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.pp-menu { position: absolute; top: 54px; right: 0; z-index: 20; min-width: 172px; padding: 6px; border-radius: 14px; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .18), 0 0 0 1px rgba(0, 0, 0, .06); }
.pp-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px; border-radius: 10px; background: none; color: var(--text); font-size: 15px; font-weight: 600; text-align: left; white-space: nowrap; }
.pp-menu button.on { background: var(--box); }
.pp-menu button .ck { visibility: hidden; flex: none; }
.pp-menu button.on .ck { visibility: visible; }

/* ===== 遊戲格 ===== */
/* 手機三個一排、寬螢幕四個一排；--ico＝圖示最大寬度 */
.grid { --ico: 104px; }
@media (min-width: 520px) { .grid { --ico: 122px; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } .tile .nm { font-size: 16px; } .tile .meta { font-size: 13px; } }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 12px; margin: 0 0 26px; }
.tile { position: relative; min-width: 0; text-align: center; }
.tile a { display: block; color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.tile a:active .ico { transform: scale(.95); }
.tile .ico { display: block; width: 100%; max-width: var(--ico); height: auto; aspect-ratio: 1; margin: 0 auto 6px; border-radius: 22.5%; transition: transform .12s; background: var(--box); }
.tile .nm { display: block; font-size: 15px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .meta { display: block; margin-top: 3px; font-size: 12px; line-height: 1.3; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 更新按鈕：有新版時出現在圖示右上角 */
.upd { padding: 6px 12px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 13px; font-weight: 700; line-height: 1.2; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .22); }
.upd:disabled { opacity: .75; cursor: default; }
/* 圖示寬度＝min(格寬, --ico) 且置中，所以圖示左右緣距離格子邊＝50% - min(50%, --ico 的一半) */
.tile .upd { position: absolute; top: -8px; right: calc(50% - min(50%, var(--ico) / 2) - 6px); z-index: 2; }
/* 我的最愛：名稱右邊的小愛心（沒加入＝灰色空心，加入＝紅色實心），點了切換；名稱＋愛心一起置中 */
.tile .nmrow { display: flex; align-items: center; justify-content: center; gap: 1px; min-width: 0; }
.tile .nmrow .nm { min-width: 0; color: inherit; text-decoration: none; }
.tile .fav { flex: none; display: flex; align-items: center; justify-content: center; width: 21px; height: 26px; margin: -3px -4px -3px 0; padding: 0; background: none; color: #b0b0b0; touch-action: manipulation; }
.tile .fav svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }
.tile .fav.on { color: var(--danger); }
.tile .fav.on svg { fill: currentColor; }
.tile .fav:active { transform: scale(.85); }
/* 窄螢幕（小於 iPhone 16 Pro）：名稱縮一級，讓最長的「1A2B 猜數字」加愛心放得下 */
@media (max-width: 395px) { .tile .nm { font-size: 14px; letter-spacing: -.2px; } .grid { gap: 18px 8px; } }
.top .upd { flex: none; margin-bottom: 2px; }

.empty { margin: 0 0 26px; padding: 24px 0; text-align: center; color: var(--muted); font-size: 15px; background: var(--box); border-radius: 16px; }
.studio-foot { margin: 0 auto; padding: 8px 16px 0; width: max-content; max-width: 100%; text-align: center; font-size: 12px; color: #111; user-select: none; -webkit-user-select: none; }
.foot { margin: 0 auto; padding: 8px 16px; width: max-content; max-width: 100%; text-align: center; font-size: 12px; color: var(--muted); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* 網址清單彈窗（版號連點 5 下才出現）：名稱（點了複製網址）｜網址（點了前往）｜版號 */
.umodal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(0, 0, 0, .55); }
.ubox { width: 100%; max-width: 460px; max-height: 100%; display: flex; flex-direction: column; padding: 14px 12px 12px; border-radius: 18px; background: var(--bg); }
.uhead { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 0 8px; font-size: 17px; font-weight: 800; }
.uhead button { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -4px -4px -4px 0; padding: 0; border-radius: 50%; background: none; color: var(--text); }
.uhead button:active { background: var(--box); }
.uhint { margin: 2px 8px 10px; font-size: 12px; color: var(--muted); }
.urls { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px; border-radius: 14px; background: var(--box); font-size: 13px; }
.urls .row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 10px; }
.urls .row:nth-child(odd) { background: rgba(0, 0, 0, .04); }
.urls .n { flex: none; width: 7.2em; padding: 8px 6px; border-radius: 8px; background: none; color: var(--text); font-size: 13px; font-weight: 700; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; touch-action: manipulation; }
.urls .n:active { background: rgba(0, 0, 0, .1); }
.urls .n.ok { color: var(--ok); }
.urls a { flex: 1; min-width: 0; padding: 6px 0; color: var(--text); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.urls .v { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 點遊戲進入前：被點的圖示放大 1.3 倍並移到畫面中間、其餘內容淡出（約 0.4 秒），之後才跳頁；遊戲頁從圖示位置展開 */
.tile .ico { transition: transform .4s cubic-bezier(.4,0,.2,1); }
.tile.picked { position: relative; z-index: 50; }
body.leaving .head, body.leaving .studio-foot, body.leaving .foot, body.leaving .tile:not(.picked), body.leaving .tile.picked .nmrow, body.leaving .tile.picked .meta { opacity: 0; transition: opacity .2s ease-in; }
body.leaving .tile.picked .ico { transform: translate(var(--dx), var(--dy)) scale(1.3); }
@media (prefers-reduced-motion: reduce) { .tile .ico, body.leaving * { transition: none !important; } }

/* 從遊戲回大廳（不播開場動畫時）：內容淡入＋上滑 */
@keyframes lobby-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
html.no-intro body { animation: lobby-in .32s ease-out both; }
@media (prefers-reduced-motion: reduce) { html.no-intro body { animation: none; } }
