/* =========================================================
 * 骰子電玩城 — 進入畫面與大廳（黃橘色派對桌遊風）
 * 構圖參考：左側房間資訊與設定、左下聊天、右側 4×2 大型角色卡
 * 背景圖案為原創 SVG（骰子、星星、錢袋、愛心），不使用外部素材
 * ========================================================= */
:root {
  --sun: #ffc93c;
  --ink-y: #5a3a0a;
  --cream: #fff3d6;
  --orange: #ff922b; --orange-d: #d9480f;
  --teal: #20c997;   --teal-d: #087f5b;
}

body.party-mode {
  background-color: var(--sun);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='%23ffe08a' fill-opacity='.55'%3E%3Crect x='22' y='24' width='40' height='40' rx='10' transform='rotate(-14 42 44)'/%3E%3Cpath d='M160 30l7 15 16 2-12 11 3 16-14-8-14 8 3-16-12-11 16-2z'/%3E%3Cpath d='M40 150c0-12 10-20 22-20s22 8 22 20v18H40z'/%3E%3Ccircle cx='62' cy='126' r='8'/%3E%3Cpath d='M165 140c12-14 32-4 22 12l-22 22-22-22c-10-16 10-26 22-12z'/%3E%3Ccircle cx='112' cy='100' r='14'/%3E%3C/g%3E%3Cg fill='%23ffc93c'%3E%3Ccircle cx='35' cy='38' r='4'/%3E%3Ccircle cx='50' cy='52' r='4'/%3E%3Ccircle cx='112' cy='100' r='6'/%3E%3C/g%3E%3C/svg%3E");
}
body.party-mode .topbar { color: var(--ink-y); padding-top: 6px; padding-bottom: 6px; }
body.party-mode .logo { color: var(--ink-y); text-shadow: 0 2px 0 #fff3bf; }

/* 共用：米色卡片（虛線內框）、立體按鈕 */
.ycard {
  background: var(--cream);
  border-radius: 18px;
  box-shadow: 0 5px 0 #e0a42a, inset 0 0 0 3px #fff8e6;
  outline: 2px dashed rgba(224, 164, 42, .35);
  outline-offset: -9px;
  color: var(--ink-y);
}
.btn3d {
  --bg: #fff; --bd: #e0c9a6; --fg: var(--ink-y);
  border: 0; border-radius: 14px; padding: .6em 1.2em;
  font: inherit; font-weight: 900; font-size: 15px; color: var(--fg); background: var(--bg);
  box-shadow: 0 5px 0 var(--bd); cursor: pointer; transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn3d:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd); }
.btn3d:disabled { filter: grayscale(.6); opacity: .55; cursor: not-allowed; }
.btn3d.orange { --bg: var(--orange); --bd: var(--orange-d); --fg: #fff; }
.btn3d.yellow { --bg: #ffd43b; --bd: #e67700; }
.btn3d.teal { --bg: var(--teal); --bd: var(--teal-d); --fg: #fff; }
.btn3d.white { --bg: #fff; --bd: #e0c9a6; }
.btn3d.small { font-size: 13px; padding: .4em .8em; border-radius: 11px; }

/* ---------- 進入畫面 ---------- */
#entryScreen { display: flex; justify-content: center; padding: 8px 16px 32px; }
.entry-card, .panel3d { background: var(--cream); border-radius: 22px; padding: 16px 18px; box-shadow: 0 6px 0 #e0a42a; color: var(--ink-y); }
.entry-card { width: min(640px, 100%); }
.entry-hero { text-align: center; }
.hero-dice { font-size: 54px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(8deg); } }
.entry-hero h1 { margin: 0; font-size: 34px; color: var(--orange-d); text-shadow: 0 3px 0 #fff; }
.entry-hero p { margin: 4px 0 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; margin: 8px 0; }
.field .name-input { max-width: none; }
.entry-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.entry-box { background: #fff; border-radius: 18px; padding: 12px; text-align: center; box-shadow: inset 0 0 0 2px #ffe8cc; }
.entry-box h3 { margin: 2px 0 6px; }
.entry-box .name-input { margin: 0 auto 10px; }
.hint.center { text-align: center; }

/* ---------- 大廳：整個畫面一次看完（約 900 像素高的桌機不需捲動） ---------- */
#lobbyScreen { display: block; padding: 0 14px 10px; }
#lobbyScreen.hidden, #entryScreen.hidden { display: none !important; }
.lobby3 {
  display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px;
  max-width: 1500px; margin: 0 auto;
  height: calc(100vh - var(--top-h, 54px) - 16px); min-height: 640px;
}
.l-left { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.l-room { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; overflow-y: auto; }
.l-title-row { display: flex; align-items: center; gap: 8px; }
.tag-btn { border: 0; border-radius: 10px; padding: .35em .7em; background: var(--orange); color: #fff; font: inherit; font-weight: 900; font-size: 13px; box-shadow: 0 3px 0 var(--orange-d); transform: rotate(-3deg); cursor: pointer; }
.l-title { flex: 1; text-align: center; padding: 6px 10px; border-radius: 12px; background: linear-gradient(#ffd66b, #ffbf2e); color: #fff; font-weight: 900; font-size: 17px; text-shadow: 0 2px 0 #d98a00; box-shadow: 0 3px 0 #e0a42a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-code { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: #fff8e6; font-weight: 800; color: #e8890c; flex-wrap: wrap; }
.l-code b { letter-spacing: 3px; font-size: 18px; }
.mini-btn { margin-left: auto; border: 0; border-radius: 8px; padding: .25em .6em; background: #fff; color: var(--ink-y); font: inherit; font-weight: 800; font-size: 12px; box-shadow: 0 2px 0 #e0c9a6; cursor: pointer; }
.mini-btn + .mini-btn { margin-left: 0; }
.mini-btn.hot { background: #ffd43b; box-shadow: 0 2px 0 #e67700; }
.share-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.l-map { border-radius: 14px; overflow: hidden; background: #fff; box-shadow: 0 3px 0 #e0c9a6; flex: none; }
.l-map-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: #37b24d; color: #fff; font-size: 14px; }
.map-only { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, .25); }
.l-map-body { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: center; padding: 8px; }
.map-preview { width: 96px; height: 96px; border-radius: 10px; }
.l-map-body .hint { margin: 0; font-size: 12px; }
.l-settings-head { font-weight: 900; font-size: 14px; }
.l-settings { display: flex; flex-direction: column; gap: 6px; }
.set-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; background: #fff; box-shadow: 0 2px 0 #f0d9a8; font-weight: 800; font-size: 14px; }
.set-value { color: #e8890c; }
.set-select { border: 0; border-radius: 8px; padding: 3px 6px; background: #fff3d6; color: #e8890c; font: inherit; font-weight: 900; cursor: pointer; }
.victory-help { margin: 2px 0 0; padding: 7px 10px; border-radius: 10px; background: #fff8e6; font-size: 12px; line-height: 1.55; }
.future-note { padding: 5px 10px; border-radius: 10px; background: rgba(0, 0, 0, .05); color: #9a7b4f; font-size: 12px; font-weight: 700; }
.lobby-hint { margin: auto 0 0; font-weight: 800; font-size: 13px; color: var(--orange-d); text-align: center; }
/* 準備／開始：左側卡片內容較多（或視窗較矮）而需要捲動時，固定在卡片底部，永遠按得到 */
.l-buttons { display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: -16px; z-index: 2; margin: 0 -6px -6px; padding: 8px 6px 10px; background: var(--cream); border-radius: 0 0 14px 14px; box-shadow: 0 -6px 8px -6px rgba(224, 164, 42, .45); }
.big-ready {
  border: 0; border-radius: 14px; padding: .55em 1em; width: 100%;
  background: linear-gradient(#ffad3b, #ff8c1a); color: #fff; font: inherit; font-weight: 900; font-size: 20px; letter-spacing: 4px;
  box-shadow: 0 5px 0 #c96a00, inset 0 0 0 2px rgba(255, 255, 255, .35); outline: 2px dashed rgba(255, 255, 255, .6); outline-offset: -7px; cursor: pointer;
}
.big-ready:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #c96a00; }
.big-ready.done { background: linear-gradient(#fff, #f1f3f5); color: var(--ink-y); box-shadow: 0 5px 0 #c9b38a; }
.big-ready.start { background: linear-gradient(#38d9a9, #12b886); box-shadow: 0 5px 0 #087f5b; }
.big-ready:disabled { filter: grayscale(.7); opacity: .6; cursor: not-allowed; }

/* 聊天與遊戲紀錄（大廳左下、對局左下共用，可收合） */
.l-chat { flex: none; background: rgba(255, 243, 214, .94); border-radius: 16px; padding: 8px 10px; box-shadow: 0 4px 0 #e0a42a; color: var(--ink-y); }
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: 6px; }
.tab { border: 0; border-radius: 10px 10px 4px 4px; padding: .3em .8em; font: inherit; font-weight: 800; font-size: 13px; background: #ffe8b3; color: var(--ink-y); cursor: pointer; }
.tab.active { background: var(--orange); color: #fff; box-shadow: 0 2px 0 var(--orange-d); }
.chat-toggle { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--ink-y); padding: 2px 8px; }
.chat-panel.folded .chat-body { display: none; }
.chat-list { list-style: none; margin: 6px 0; padding: 0; height: 104px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.chat-list li { line-height: 1.45; word-break: break-word; }
.chat-list .who { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 999px; color: #fff; font-weight: 800; font-size: 12px; }
.chat-list .chat-empty { color: #b08a5c; }
.chat-form { display: flex; gap: 6px; }
.chat-input { flex: 1; min-width: 0; padding: 7px 10px; border: 2px solid #ffd8a8; border-radius: 10px; font: inherit; font-size: 14px; background: #fff; }
.send-btn { border: 0; border-radius: 10px; padding: 0 16px; background: var(--orange); color: #fff; font: inherit; font-weight: 900; box-shadow: 0 3px 0 var(--orange-d); cursor: pointer; }
.send-btn:disabled { opacity: .6; }

/* ---------- 右側：4×2 大型角色卡（8 個席位） ---------- */
.l-seats { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.seats-note { font-weight: 800; font-size: 13px; color: var(--ink-y); }
.seat-grid3 { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card3 {
  --pc: #adb5bd;
  position: relative; display: flex; flex-direction: column; min-height: 0;
  border-radius: 18px; background: repeating-linear-gradient(0deg, #f8e2ad 0 6px, #f6dca2 6px 12px);
  box-shadow: 0 5px 0 #e0a42a, inset 0 0 0 3px #fff3d6; color: var(--ink-y); overflow: hidden;
}
.card3::after { content: ''; position: absolute; inset: 8px; border: 2px dashed rgba(224, 164, 42, .45); border-radius: 12px; pointer-events: none; }
.card3.me { cursor: pointer; box-shadow: 0 5px 0 #e0a42a, 0 0 0 4px var(--pc); }
.card3.me:hover { filter: brightness(1.03); }
.card3.me:focus-visible { outline: 4px solid #fff; }
.card3.offline .c3-art { filter: grayscale(.8); opacity: .6; }
.c3-name { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin: 8px 8px 0; padding: 6px 10px 6px 6px; border-radius: 12px; background: #15121c; color: #fff; font-size: 17px; }
.c3-name .pad { display: grid; place-items: center; width: 36px; height: 28px; border-radius: 9px; background: var(--pc); font-size: 16px; }
.c3-name b { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c3-name small { padding: 1px 6px; border-radius: 999px; background: var(--pc); font-size: 11px; font-weight: 800; }
.c3-tags { position: relative; z-index: 1; display: flex; gap: 6px; align-items: center; min-height: 26px; padding: 6px 12px 0; }
.c3-host { padding: 2px 8px; border-radius: 8px; background: #ffd43b; color: #fff; font-weight: 900; font-size: 12px; text-shadow: 0 1px 0 #d98a00; box-shadow: 0 2px 0 #e0a42a; }
.c3-off { padding: 2px 8px; border-radius: 8px; background: #868e96; color: #fff; font-weight: 800; font-size: 12px; }
.c3-wheel { margin-left: auto; width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; background: conic-gradient(red, orange, yellow, lime, cyan, blue, magenta, red); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.c3-art { position: relative; flex: 1; min-height: 0; margin: 2px 12px 4px; border-radius: 16px; background: radial-gradient(circle at 50% 60%, #fffdf6 0, #fff3dc 75%); box-shadow: inset 0 0 0 2px #fff; overflow: hidden; }
/* 立繪填滿圖片區（取景時已經留好安全邊，不會裁到耳朵、帽子、翅膀、尾巴） */
.c3-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.c3-ready { position: absolute; right: 14px; bottom: 58px; z-index: 2; padding: 3px 10px; border-radius: 999px; background: #d3f9d8; color: var(--teal-d); font-weight: 900; font-size: 13px; box-shadow: 0 2px 0 #8ce99a; }
.c3-char {
  position: relative; z-index: 1; margin: 0 14px 14px; padding: 7px 10px; border-radius: 12px; text-align: center;
  background: var(--pc); color: #fff; font-weight: 900; font-size: 20px; letter-spacing: 2px; text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--pc) 70%, #000), inset 0 0 0 2px rgba(255, 255, 255, .3); outline: 2px dashed rgba(255, 255, 255, .5); outline-offset: -6px;
}
.c3-char small { margin-left: 6px; font-size: 12px; letter-spacing: 0; opacity: .9; }
.card3.empty { background: rgba(255, 243, 214, .55); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .6); }
.c3-wait { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 900; color: #c08a3e; }
.c3-wait span { font-size: 48px; line-height: 1; opacity: .5; }
.c3-wait small { font-weight: 700; font-size: 12px; }
/* 電腦玩家 */
.c3-addbot { position: relative; z-index: 1; margin-top: 8px; padding: 6px 14px; border: 0; border-radius: 12px; background: #5c7cfa; color: #fff; font: inherit; font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: 0 3px 0 #3b5bdb; }
.c3-addbot:hover { filter: brightness(1.08); }
.c3-addbot:disabled { opacity: .6; cursor: default; }
.c3-bot { padding: 2px 8px; border-radius: 8px; background: #5c7cfa; color: #fff; font-weight: 900; font-size: 12px; box-shadow: 0 2px 0 #3b5bdb; }
.c3-bottools { position: relative; z-index: 2; display: flex; gap: 6px; margin: 0 14px 6px; }
.c3-botchar { flex: 1; min-width: 0; padding: 4px 6px; border: 2px solid #fff; border-radius: 10px; background: #fffdf6; color: var(--ink-y); font: inherit; font-weight: 800; font-size: 13px; }
.c3-botdel { padding: 4px 8px; border: 0; border-radius: 10px; background: #fa5252; color: #fff; font: inherit; font-weight: 900; font-size: 12px; cursor: pointer; box-shadow: 0 2px 0 #c92a2a; white-space: nowrap; }
.card3.bot:has(.c3-bottools) .c3-ready { bottom: 96px; }
.emoji-art { font-size: 72px; line-height: 1; }
.emoji-art.big { font-size: 120px; }

/* ---------- 角色衣櫃 ---------- */
.wardrobe { width: min(860px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.wd-head { display: flex; justify-content: space-between; align-items: center; }
.wd-head h2 { margin: 0; color: var(--orange-d); }
.wd-main { display: grid; grid-template-columns: 300px 1fr; gap: 16px; margin-top: 8px; }
.wd-stage { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wd-preview { --pc: #ffa94d; width: 280px; height: 280px; border-radius: 26px; display: grid; place-items: center; background: radial-gradient(circle at 50% 62%, #fffdf6 0, #fff3dc 72%); border: 4px solid var(--pc); }
.wd-preview canvas { width: 100% !important; height: 100% !important; }
.wd-name b { font-size: 22px; }
.wd-name small { margin-left: 6px; color: #9c6b2b; font-weight: 700; }
.wd-intro { margin: 0 0 8px; }
.skill-toggle { width: 100%; text-align: left; border: 0; border-radius: 12px; padding: 8px 10px; background: #f3f0ff; color: #5f3dc4; font: inherit; cursor: pointer; }
.wd-skill { margin: 6px 0; padding: 8px 10px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 2px #e5dbff; line-height: 1.6; }
.wardrobe h4 { margin: 12px 0 6px; }
.wd-chars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wd-char { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border: 3px solid transparent; border-radius: 16px; background: #fff; box-shadow: 0 3px 0 #e0c9a6; font: inherit; color: var(--ink-y); cursor: pointer; }
.wd-char.on { border-color: var(--orange); background: #fff4e6; }
.wd-char small { font-size: 11px; color: #9c6b2b; text-align: center; }
.wd-thumb { width: 84px; height: 70px; object-fit: contain; border-radius: 12px; background: #fff6e3; }
.wd-char .emoji-art { font-size: 40px; }
.wd-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.wd-color { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 3px solid transparent; border-radius: 999px; background: #fff; box-shadow: 0 3px 0 #e0c9a6; font: inherit; font-size: 13px; font-weight: 800; color: var(--ink-y); cursor: pointer; }
.wd-color span { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.wd-color.on { border-color: var(--c); }
.wd-color:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.wd-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 平板：席位改 2 欄、可捲動 ---------- */
@media (max-width: 1100px) {
  .lobby3 { grid-template-columns: 300px minmax(0, 1fr); }
  .seat-grid3 { grid-template-columns: repeat(2, 1fr); grid-template-rows: none; grid-auto-rows: minmax(230px, 1fr); overflow-y: auto; }
}
/* ---------- 手機：上下排列；準備按鈕固定在畫面下方 ---------- */
@media (max-width: 760px) {
  .lobby3 { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .l-left, .l-room { display: contents; }
  .l-title-row { order: 1; } .l-code { order: 2; }
  .l-seats { order: 3; }
  .l-settings-head { order: 4; } .l-settings { order: 5; } .future-note { order: 6; }
  .l-map { order: 7; }
  .l-chat { order: 8; }
  .lobby-hint { order: 9; margin: 0; }
  .l-buttons { position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 20; flex-direction: row; margin: 0; padding: 8px; border-radius: 16px; background: rgba(255, 243, 214, .96); box-shadow: 0 4px 0 #e0a42a; }
  .l-buttons .big-ready { font-size: 18px; padding: .5em; }
  #lobbyScreen { padding-bottom: 90px; }
  .seat-grid3 { grid-template-columns: repeat(2, 1fr); grid-template-rows: none; grid-auto-rows: 230px; }
  .seat-grid3:has(.c3-bottools) { grid-auto-rows: 275px; }
  .c3-name { font-size: 14px; } .c3-char { font-size: 16px; margin: 0 10px 10px; }
  .entry-actions { grid-template-columns: 1fr; }
  .wd-main { grid-template-columns: 1fr; }
  .wd-preview { width: 220px; height: 220px; }
}
/* 角色變多（11 位）：格子不被長暱稱撐寬，寬螢幕排 4 欄；整個衣櫃視窗可以捲動 */
.wd-chars { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wd-char { min-width: 0; }
.wd-char b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-char small { max-width: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 760px) { .wd-chars { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .wd-chars { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .wd-char { padding: 4px; } .wd-char b { font-size: 13px; } }
