/* Candy Town · isometric art direction.
   Presentation only: all game controls retain their original IDs and behavior. */
:root {
  --ui-text: 16px;
  --ui-small: 14px;
  --ui-title: 24px;
  --ink: #334342;
  --ink-soft: #73817a;
  --paper: #fffdf5;
  --cream: #f7f2e5;
  --line: #d9ddc9;
  --teal: #316d63;
  --teal-deep: #28584f;
  --teal-pale: #e8efe3;
  --coral: #d77b58;
  --honey: #eeb657;
  --shadow: 0 12px 40px #304c3c20, 0 3px 0 #33434212;
}

/* The interface shares the scene's crisp frame and restrained three-tone trim. */
body { background: #161b1b; }
canvas#game { image-rendering: pixelated; }
button.px, .pixel-box, .panel, .hud-chip, #toolbar, #chatLog, #chatBar input,
.map-card, .item-card, .quest-card, .bag-info, .npc-dialog, .diary-card,
.trade-side, .stock-list, .dm-log, #ctxMenu, #photoBar, #editHint, #toast {
  border-radius: 3px;
}

body {
  color: var(--ink);
  background: #b7d2b4;
  font-family: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', sans-serif;
  -webkit-font-smoothing: antialiased;
  image-rendering: auto;
}
canvas#game, canvas { image-rendering: auto; }
button, input, textarea { font-family: inherit; }
input, textarea { user-select: text; }
button.px {
  color: var(--ink);
  background: #f2e3ba;
  border: 1px solid #b4b8a2;
  border-radius: 7px;
  box-shadow: 0 2px 0 #81907830;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s, box-shadow .15s, transform .15s, border-color .15s;
}
button.px:hover { background: #f8edcf; border-color: #7e9981; box-shadow: 0 3px 0 #81907830; }
button.px:active { transform: translateY(1px); box-shadow: 0 0 0 transparent; }
button.px:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #d89958; outline-offset: 3px; }
button.px.alt { background: #dcebe2; border-color: #93b2a1; color: #316656; }
button.px.alt:hover { background: #eaf3eb; }
button.px.danger { background: #f7e2d7; border-color: #dab0a0; color: #985d47; }
button.px.danger:hover { background: #fbeae3; }
button.px.on { background: var(--teal); border-color: var(--teal); color: var(--paper); }
button.px.small { padding: 5px 9px; }
button.px.tiny { border-radius: 4px; padding: 2px 6px; font-size: 11px; }
button.px.big { padding: 11px 22px; border-radius: 9px; }
button.px.disabled { opacity: .5; }
.pixel-box {
  border: 1px solid #7c8b79;
  border-radius: 13px;
  background: var(--paper);
  box-shadow: var(--shadow), inset 0 0 0 4px #ffffff66;
}

/* Login uses direct account labels; the illustration is the actual game world. */
#login {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0 6.2vw;
  overflow: auto;
  background: radial-gradient(ellipse at 17% 69%, #e4ecce99, transparent 45%), #f8f5e9;
  color: var(--ink);
}
#login::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .26;
  background-image: radial-gradient(#a5ac8c 0.6px, transparent 0.6px);
  background-size: 5px 5px;
}
.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 99px;
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  border-bottom: 1px solid #dadfce;
}
.town-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--teal); font-size: 20px; font-weight: 800; letter-spacing: 3px; }
.brand-candy {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--paper);
  background: var(--teal);
  border: 1px solid var(--teal-deep);
  border-radius: 13px 13px 12px 4px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
  transform: rotate(-7deg);
  box-shadow: 3px 3px 0 #e9c994;
}
.town-brand small { display: block; margin-top: 3px; font-size: 8px; font-weight: 700; letter-spacing: 4px; }
.welcome-tag { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: 1.6px; color: #7b8b79; }
.welcome-tag i, .town-art-note i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #80a68b; box-shadow: 0 0 0 3px #80a68b18; }
.welcome-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  align-items: center;
  column-gap: clamp(28px, 5.5vw, 90px);
  width: 100%;
  max-width: 1190px;
  margin: 0 auto;
  padding: 28px 0 30px;
}
.welcome-world { align-self: center; min-width: 0; padding-top: 4px; }
.welcome-eyebrow { display: flex; gap: 10px; align-items: center; font-size: 9px; letter-spacing: 2.7px; font-weight: 700; color: #8b957c; }
.welcome-eyebrow > span { width: 27px; height: 1px; background: var(--coral); }
#login h1 { margin: 0 0 10px; color: var(--teal-deep); font-size: clamp(32px, 3.35vw, 48px); line-height: 1.36; letter-spacing: 3px; font-weight: 900; text-shadow: none; }
#login h1 > span { color: var(--coral); }
.welcome-description { position: relative; z-index: 1; font-size: 12px; line-height: 2; color: #7f8a78; letter-spacing: .5px; }
.town-art { position: relative; height: clamp(285px, 38vh, 400px); margin: -5px -42px 0 -50px; }
#townPreview { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: contain; z-index: 1; }
.town-art-sun { position: absolute; width: 235px; height: 235px; border-radius: 50%; top: 5%; left: 33%; background: #eddfa755; }
.town-art-note { position: absolute; z-index: 2; top: 19%; right: 4%; display: flex; align-items: center; gap: 8px; transform: rotate(4deg); padding: 9px 13px; font-size: 10px; letter-spacing: .7px; color: #74836c; border: 1px solid #d9decb; border-radius: 5px; background: #fffdf1e8; box-shadow: 0 3px 0 #6d7e5c0c; }
.town-art-caption { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 8px; letter-spacing: 2.6px; color: #9ca68e; white-space: nowrap; }
.town-art-caption span { color: var(--coral); margin-left: 11px; font-size: 12px; }
#login .welcome-card {
  position: relative;
  padding: 30px 34px 34px;
  width: 100%;
  text-align: center;
  border: 1px solid #c7d1b8;
  border-radius: 15px;
  background: #fffdf5;
  box-shadow: 0 15px 50px #71805e0c, 0 5px 0 #e4e8d9;
}
#login .welcome-card::before { content: ''; position: absolute; height: 4px; width: 55px; top: -2px; left: calc(50% - 27px); background: var(--coral); border-radius: 2px; }
.welcome-card-label { font-size: 7px; font-weight: 700; letter-spacing: 2px; color: #9da78d; }
.welcome-avatar { position: relative; width: 90px; height: 110px; margin: 7px auto 5px; background: radial-gradient(ellipse at 50% 58%, #ebf1e3 0 58%, transparent 60%); }
#loginCanvas { width: 80px; height: 100px; position: absolute; bottom: 3px; left: 5px; margin: 0; }
.avatar-spark { position: absolute; right: 1px; top: 7px; color: var(--coral); font-size: 18px; transform: rotate(13deg); }
.welcome-card h2 { margin: 8px 0 18px; font-size: 23px; letter-spacing: 1px; line-height: 1.55; color: var(--teal-deep); font-weight: 800; }
#login .welcome-card .sub { margin: 5px 0 0; font-size: 11px; color: #98a08c; letter-spacing: .6px; }
#loginErr { color: #bb654a; min-height: 20px; margin: 3px 0 4px; font-size: 11px; line-height: 20px; }
.login-label { display: flex; justify-content: space-between; align-items: center; margin: 0 0 7px; font-size: 11px; text-align: left; font-weight: 700; letter-spacing: .4px; color: #657361; }
.login-label span { font-size: 7px; letter-spacing: 1.4px; color: #a6ad9b; font-weight: 400; }
#login input { height: 43px; width: 100%; margin: 0 0 16px; padding: 10px 13px; border: 1px solid #dce1ce; border-radius: 6px; background: #fafaf1; color: var(--ink); font-size: 12px; letter-spacing: .4px; transition: border-color .15s, background .15s; }
#login input:focus { border-color: #789985; background: #fff; outline: 2px solid #bed2b830; outline-offset: 1px; }
#login input::placeholder { color: #adb5a2; font-size: 11px; }
#login #loginPass { margin-bottom: 10px; }
.login-tip { margin: 0 0 18px; font-size: 9px; color: #9a9f8b; text-align: left; line-height: 1.6; }
#login #loginBtn { display: flex; align-items: center; justify-content: center; gap: 16px; width: 100%; height: 46px; border: 1px solid var(--teal-deep); border-radius: 6px; background: var(--teal); color: #fffbee; font-size: 13px; font-weight: 700; letter-spacing: 2px; box-shadow: 0 3px 0 #1c4b421f; }
#login #loginBtn:hover { background: #3d7a6c; box-shadow: 0 4px 0 #1c4b421f; }
#login #loginBtn span { font-size: 17px; font-weight: 400; }
.welcome-card-foot { display: flex; justify-content: space-between; align-items: center; margin: 23px -34px 0; padding: 16px 27px; border-top: 1px solid #e7eadb; font-size: 9px; letter-spacing: .4px; color: #98a187; background: #f6f8ed; border-radius: 0 0 15px 15px; }
.welcome-card-foot span { color: #c89868; font-size: 11px; }
.welcome-footer { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 1260px; min-height: 54px; margin: 0 auto; border-top: 1px solid #dadfce; color: #9ba48e; font-size: 9px; letter-spacing: 1px; }
.welcome-footer i { font-style: normal; color: var(--coral); margin: 0 8px; }
.welcome-footer > span:last-child { font-size: 7px; letter-spacing: 2px; }

/* In-world chrome: compact stationery controls, leaving room for the town. */
#hud { top: 18px; left: 20px; gap: 6px; max-width: calc(100vw - 260px); }
.hud-chip { display: flex; align-items: center; gap: 5px; min-height: 33px; padding: 7px 10px; background: #fffdf3ef; border: 1px solid #acb99d; border-radius: 7px; color: #45594c; font-size: 12px; font-weight: 700; box-shadow: 0 2px 0 #45594c19; backdrop-filter: blur(8px); }
.hud-chip.usd { color: #47745a; background: #e8f0dcf5; }
.hud-chip.dim { background: #f7f5e8db; color: #7f8f77; font-size: 10px; }
#mapName { position: relative; gap: 8px; padding: 8px 15px; background: var(--teal-deep); border-color: #305a4c; color: #fff6d6; letter-spacing: .7px; font-size: 13px; }
#mapName::before { content: '✦'; color: #e5bb68; font-size: 16px; }
#hudName { color: #947852; }
#bgmBtn { min-height: 33px; background: #fffdf3ee; border-color: #acb99d; }
#toolbar { top: 18px; right: 18px; grid-template-columns: repeat(2, 1fr); gap: 6px; width: 216px; padding: 38px 9px 10px; border: 1px solid #8b9e81; border-radius: 12px; background: #f8f7e9f0; box-shadow: 0 5px 0 #435b3a14, 0 8px 25px #435b3a14; backdrop-filter: blur(8px); }
#toolbar::before { content: '✦ 小 鎮 手 帳'; position: absolute; top: 12px; left: 13px; font-size: 10px; font-weight: 700; letter-spacing: 1px; color: #758169; }
#toolbar::after { content: 'CANDY TOWN'; position: absolute; top: 14px; right: 12px; font-size: 6px; letter-spacing: 1px; color: #a1aa92; }
#toolbar button { min-width: 0; min-height: 36px; padding: 7px 4px; background: #fffdf6; border: 1px solid #d6dec7; font-size: 12px; color: #5c6c55; box-shadow: 0 2px 0 #8b9e810c; }
#toolbar button:hover { background: #eef2df; border-color: #94aa84; transform: translateY(-1px); }
#toolbar #btnHome { background: #e6ecda; color: #37634d; border-color: #afc09c; }
#toolbar #btnEdit { color: #a1734f; background: #faf0dc; border-color: #dfcfb2; }
#chatLog { left: 20px; bottom: 70px; width: 330px; max-height: 155px; background: #fffdf2df; border: 1px solid #aebd9b; border-radius: 10px; padding: 10px 13px; font-size: 12px; line-height: 1.75; color: #61705a; box-shadow: 0 3px 0 #435b3a0d; backdrop-filter: blur(8px); }
#chatLog .nm { color: #397b6c; }
#chatLog .sys { color: #8b977e; font-size: 11px; font-style: normal; }
#chatLog .gain { color: #4a8b61; }
#chatBar { left: 20px; bottom: 20px; width: 330px; gap: 7px; }
#chatInput { min-width: 0; padding: 10px 12px; background: #fffdf3f5; border: 1px solid #aebd9b; border-radius: 7px; font-size: 12px; color: #4e6354; box-shadow: 0 2px 0 #435b3a10; }
#chatInput::placeholder { color: #96a18c; }
#chatSend { background: var(--teal); color: #fffdf3; border-color: var(--teal-deep); }
#chatSend:hover { background: #448372; }

/* All panels share the same paper-and-ink visual language. */
.panel { max-height: 84vh; overflow: hidden; }
.panel-head { flex-shrink: 0; min-height: 53px; background: #e9b16e; color: #4e4f39; border-bottom: 1px solid #bc9763; padding: 10px 15px; font-size: 15px; letter-spacing: .5px; box-shadow: inset 0 1px 0 #fff5d5; }
.panel-head > .danger { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-color: #b48e60; background: #f5d49c; color: #7e6543; border-radius: 50%; box-shadow: none; font-size: 11px; }
.panel-head > .danger:hover { background: #fff0cb; }
.panel-body { padding: 17px; scrollbar-color: #b6c0a3 #f1f2e5; scrollbar-width: thin; }
.tabs { gap: 7px; padding: 13px 17px 0; }
.tabs .px { background: #f2f1e4; border-color: #d6ddc5; color: #849173; box-shadow: none; padding: 6px 13px; font-size: 12px; }
.tabs .px.on { background: var(--teal); color: #fffdf2; border-color: var(--teal); }
.item-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 11px; }
.item-card { border: 1px solid #d9dfcc; border-radius: 9px; padding: 11px 7px 9px; background: #fcfcf5; color: #58684e; font-size: 11px; line-height: 1.5; transition: background .15s, border-color .15s, transform .15s; }
.item-card:hover { background: #f4f6e8; border-color: #91ab82; transform: translateY(-2px); }
.item-card.owned { border-color: #95b391; }
.item-card.equipped { background: #eaf2e1; border-color: #7ba075; box-shadow: inset 0 0 0 1px #a3bc91; }
.item-card.premium { background: #fffae8; border-color: #d4b373; box-shadow: none; }
.item-card canvas, .gacha-result canvas { image-rendering: auto; }
.item-card canvas { background: radial-gradient(ellipse at 50% 70%, #d8e5cf77, transparent 65%); border-radius: 6px; }
.item-card .price { color: #b08b48; margin-top: 3px; }
.item-card .tag { top: 6px; right: 5px; background: #6e9563; border-radius: 4px; font-size: 9px; padding: 1px 5px; }
.section-title { color: #798567; font-size: 12px; margin: 15px 0 8px; letter-spacing: .5px; }
.minitag { color: #97774e; background: #f6ebd4; border-color: #dfd1ae; padding: 2px 5px; border-radius: 4px; }
.swatch, .dw-color { border-width: 1px; border-color: #91a085; border-radius: 6px; }
.swatch.on, .dw-color.on { outline: 2px solid var(--coral); outline-offset: 2px; }
#avatarPreview, .profile-head canvas { border: 1px solid #bccbaf; border-radius: 10px; background: radial-gradient(ellipse at 50% 60%, #f6f4d8, #dfead6); }
.player-row { padding: 10px 8px; color: #66735a; font-size: 13px; border-color: #dfe4d2; }
.map-grid { gap: 13px; }
.map-card { border: 1px solid #b8c7a6; border-radius: 9px; background: #f8faee; box-shadow: 0 2px 0 #87997412; }
.map-card:hover { box-shadow: 0 4px 0 #87997421; }
.map-card canvas { border-color: #c8d3b7; border-bottom-width: 1px; image-rendering: auto; }
.map-card-name { color: #5e7051; padding: 10px 12px; letter-spacing: .5px; font-size: 12px; }
.quest-card, .bag-info, .npc-dialog, .diary-card, .trade-side, .stock-list, .dm-log, .ab-feed { border: 1px solid #d4ddc4; border-radius: 8px; background: #fcfcf5; color: #627052; }
.quest-card { padding: 13px; font-size: 13px; }
.bag-info { background: #f2f4e3; padding: 11px 13px; color: #768064; font-size: 12px; }
.npc-dialog { padding: 15px; font-size: 14px; line-height: 1.8; }
.q-ok { color: #5c9464; }
.q-no { color: #919983; }
.q-reward { color: #b29352; }
.q-reward, .q-ok { font-weight: 700; }
.gacha-result { border-width: 1px; border-color: #a9c296; border-radius: 9px; background: #f5f9ed; }
.gacha-result.rare { background: #fff9e3; border-color: #d6bd76; box-shadow: 0 0 20px #dfc47922; }
.stock-row { padding: 11px 12px; border-bottom-color: #dfe4d1; font-size: 13px; }
.stock-row:hover, .stock-row.on { background: #f0f3df; }
.stock-detail { background: #f4f5e9; border-color: #dfe4d1; }
.stock-chart { border: 1px solid #c1ccae; border-radius: 6px; }
.stock-hold, .bank-est { color: #8c977e; }
.stock-price.up, .ab-a { color: #bc7258; }
.stock-price.down, .dm-msg.mine b { color: #5b9165; }
.dm-msg b, .diary-comment b { color: #508174; }
.dm-input input, .diary-title, .diary-text { color: #5c6b52; background: #fffffa; border: 1px solid #c9d4ba; border-radius: 6px; padding: 9px 11px; font-size: 13px; }
.diary-card-text { color: #68765a; }
.diary-comments { background: #f2f5e7; border-color: #dce4cc; border-radius: 6px; }
.diary-comments-head { color: #8b947a; }
.diary-comment { border-color: #dfe5d0; }
.diary-img { border-width: 1px; border-color: #c3d1b5; border-radius: 6px; }
.trade-side.ok { background: #eef5e5; border-color: #aac69a; }
.trade-side-head { color: #889476; }
.dot { border-color: #9aaa8b; }
.dot.on { background: #7bb979; }
.game-status { color: var(--teal); }
.game-hint { color: #939c85; }
.math-q { background: var(--teal-deep); border-color: #214f45; border-width: 1px; border-radius: 10px; }
.bt-table { border-width: 1px; border-color: #34604d; border-radius: 12px; background: #53826b; }
.bt-table.holdem { background: #926356; border-color: #745149; }
.bt-card { border-width: 1px; border-color: #a9ad94; color: #5c6350; border-radius: 5px; box-shadow: 0 2px 0 #4e604a22; }
.bt-card.red { color: #ba6f55; }
.bt-card.facedown { background: #477d71; color: #d9e9cb; border-color: #39675e; }
.bt-card.sel { border-color: #6b9865; background: #edf6dc; }
.holdem-p { border: 1px solid #d3dcc2; border-radius: 7px; background: #fffef6; }
.holdem-p.turn { background: #fff7dd; border-color: #d4b66b; }
.slot-reel, .rc-item { border-width: 1px; border-color: #bac8a5; border-radius: 9px; background: #fffef6; }
.mem-card { background: #588a79; border-width: 1px; border-color: #3c6c5c; border-radius: 9px; color: #d8e4cb; box-shadow: 0 3px 0 #365a4d20; }
.mem-card.can:hover { background: #6f9b85; }
.mem-card.open { border-color: #8ba380; background: #fffdf2; }
.mem-card.m0 { background: #e2efdc; border-color: #8dab7b; }
.mem-card.m1 { background: #f6e3d8; border-color: #c0957a; }
.dw-canvas, .ds-canvas { border-width: 1px; border-color: #b5c3a3; border-radius: 8px; }
.ddr-stage { border-width: 1px; border-color: #6b7c69; border-radius: 10px; background: #374f46; }
.ddr-lane { background: #3f5e50; }
.ddr-target { color: #b1c5a5; border-color: #a3bf9866; }
.ddr-note { color: #f5d797; text-shadow: 0 2px 0 #223e3b55; }

/* Contextual feedback and little overlays. */
#editHint { top: 65px; padding: 10px 16px; border-radius: 8px; background: #355b4def; color: #f4f1d1; border: 1px solid #d6dfbf55; font-size: 11px; line-height: 1.6; box-shadow: 0 4px 0 #21463515; max-width: 76vw; text-align: center; }
#toast { top: 74px; border: 1px solid #6c8a61; background: #356c53f5; color: #fffaf0; border-radius: 9px; padding: 11px 20px; box-shadow: 0 5px 22px #39503525; font-size: 13px; }
#ctxMenu { padding: 10px; border-radius: 10px; width: 173px; }
#ctxMenu .ctx-name { color: #58724b; font-size: 13px; padding: 3px 0 8px; border-bottom: 1px solid #dbe4cd; margin-bottom: 3px; }
#ctxMenu button { font-size: 11px; background: #f4f6e8; border-color: #dae1cc; box-shadow: none; padding: 8px; }
#photoBar { padding: 9px 13px; align-items: center; border: 1px solid #98aa89; background: #f9f7e9f0; border-radius: 12px; box-shadow: var(--shadow); }
#photoBar .px.big { margin: 0; }
#stickerPicker { border: 1px solid #a7b795; border-radius: 10px; background: #fffdf0; padding: 10px; box-shadow: var(--shadow); }
.sticker-cell { border: 1px solid #d6dfc6; border-radius: 7px; background: #f9faed; }
.sticker-cell:hover { background: #edf3de; }
#fishBtn { border-radius: 10px; border-color: #9bab81; background: #fff5d1; color: #627449; font-size: 16px; box-shadow: 0 4px 0 #47623d25; }
#fishBtn.bite { background: #d78b63; color: #fff9e6; border-color: #a66d4e; }
#fishMini { background: #fffdf1; border: 1px solid #9aaf89; border-radius: 11px; padding: 11px; box-shadow: var(--shadow); }
.fm-title { color: #6b7b5c; }
.fm-track { background: linear-gradient(#a9d5c1, #4b8d83); border: 1px solid #719d85; }
.fm-prog { border-width: 1px; border-color: #a4b594; background: #e1e8d0; }
.fm-fill { background: #d7b867; }
#adBanner { border: 1px solid #c49c5c; border-radius: 10px; background: #fff2d2; color: #725c38; box-shadow: 0 5px 25px #68583225; font-size: 18px; }
#adBanner .ad-from { color: #a97a52; font-size: 11px; }
#boatOverlay { background: #284d45d9; backdrop-filter: blur(6px); }
.boat-card { border: 1px solid #b6c59c; border-radius: 15px; background: #fffbeb; color: #58704c; box-shadow: var(--shadow); padding: 29px 40px; font-size: 20px; }
.boat-card.storm { background: #43574e; color: #e6eddc; border-color: #7c9a80; }
#ytWrap { border: 1px solid #b1bea0; border-radius: 7px; overflow: hidden; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #bbc6a8; border: 2px solid #f0f2e4; border-radius: 5px; }
::-webkit-scrollbar-track { background: #f0f2e4; border-radius: 5px; }

@media (min-width: 1600px) {
  .welcome-main { grid-template-columns: minmax(0, 1fr) 385px; max-width: 1260px; }
  #login .welcome-card { padding-top: 36px; }
  .town-art { height: 450px; }
  .welcome-card-foot { padding-top: 19px; padding-bottom: 19px; }
}
@media (max-height: 760px) and (min-width: 901px) {
  .welcome-header { min-height: 77px; }
  .welcome-main { padding: 18px 0 23px; }
  #login h1 { font-size: 37px; margin-top: 14px; }
  .welcome-description { font-size: 11px; }
  .town-art { height: 275px; }
  #login .welcome-card { padding-top: 24px; }
  .welcome-avatar { margin-top: 5px; height: 98px; }
  .welcome-card-foot { margin-top: 17px; padding-top: 13px; padding-bottom: 13px; }
  .welcome-footer { min-height: 42px; }
}
@media (max-width: 1050px) {
  #login { padding: 0 4vw; }
  .welcome-main { grid-template-columns: minmax(0, 1fr) 335px; gap: 22px; }
  #login .welcome-card { padding-left: 27px; padding-right: 27px; }
  .welcome-card-foot { margin-left: -27px; margin-right: -27px; padding-left: 22px; padding-right: 22px; font-size: 8px; }
  #login h1 { letter-spacing: 1px; }
  .welcome-description { font-size: 10px; }
  .town-art-note { right: 2%; font-size: 8px; padding: 7px 9px; }
}
@media (max-width: 900px) {
  #login { padding: 0 24px; }
  .welcome-header { min-height: 79px; }
  .welcome-main { grid-template-columns: 1fr 320px; gap: 20px; padding-top: 28px; padding-bottom: 35px; }
  #login h1 { font-size: 31px; }
  .welcome-eyebrow { font-size: 7px; letter-spacing: 1.6px; }
  .welcome-eyebrow > span { width: 18px; }
  .welcome-description { line-height: 1.9; font-size: 10px; letter-spacing: 0; }
  .town-art { height: 275px; margin-right: -20px; margin-left: -32px; }
  .town-art-note { top: 10%; right: 2%; }
  .town-art-sun { width: 170px; height: 170px; }
  .welcome-tag { font-size: 9px; letter-spacing: .6px; }
  .welcome-footer { min-height: 50px; font-size: 8px; }
  .welcome-footer > span:last-child { display: none; }
  #hud { top: 11px; left: 11px; max-width: calc(100vw - 172px); gap: 4px; }
  .hud-chip { font-size: 10px; min-height: 29px; padding: 5px 7px; }
  .hud-chip.dim { font-size: 9px; }
  #mapName { font-size: 11px; padding: 6px 9px; }
  #toolbar { top: 11px; right: 11px; width: 148px; padding: 31px 6px 7px; gap: 5px; }
  #toolbar::before { font-size: 9px; left: 10px; top: 10px; }
  #toolbar::after { display: none; }
  #toolbar button { font-size: 10px; min-height: 31px; padding: 6px 0; border-radius: 5px; }
  #chatLog, #chatBar { left: 11px; width: 290px; }
  #chatBar { bottom: 12px; }
  #chatLog { bottom: 60px; }
  #editHint { top: 90px; font-size: 10px; }
}
@media (max-width: 700px) {
  #login { padding: 0 20px; }
  .welcome-header { min-height: 64px; }
  .town-brand { font-size: 17px; letter-spacing: 2px; }
  .town-brand small { font-size: 7px; letter-spacing: 3px; }
  .brand-candy { width: 34px; height: 34px; font-size: 25px; border-radius: 11px 11px 10px 4px; }
  .welcome-tag { font-size: 8px; max-width: 115px; line-height: 1.7; letter-spacing: .5px; }
  .welcome-main { display: flex; flex-direction: column; gap: 16px; width: min(100%, 410px); padding: 18px 0 22px; }
  .welcome-world { width: 100%; text-align: center; }
  .welcome-eyebrow { justify-content: center; font-size: 7px; }
  #login h1 { display: none; }
  #login h1 br { display: initial; }
  .welcome-description { font-size: 10px; }
  .town-art { height: 190px; margin: -5px -16px 0; }
  .town-art-note { right: 1%; top: 15%; font-size: 8px; }
  .town-art-sun { top: 9%; left: 35%; }
  .town-art-caption { font-size: 7px; }
  #login .welcome-card { max-width: 365px; padding-top: 22px; padding-bottom: 25px; }
  .welcome-avatar { display: none; }
  .welcome-card h2 { font-size: 21px; margin: 0 0 10px; }
  .welcome-card-label { font-size: 7px; }
  .welcome-footer { justify-content: center; text-align: center; min-height: 52px; font-size: 8px; letter-spacing: .4px; flex-shrink: 0; }
  .welcome-footer i { margin: 0 4px; }
  #hud { max-width: calc(100vw - 101px); }
  .hud-chip { padding: 4px 6px; font-size: 9px; min-height: 26px; border-radius: 5px; }
  .hud-chip.dim { font-size: 8px; }
  #mapName { font-size: 10px; }
  #toolbar { width: 80px; grid-template-columns: 1fr; max-height: calc(100vh - 155px); overflow: auto; border-radius: 9px; padding: 28px 5px 6px; }
  #toolbar::before { content: '小鎮手帳'; font-size: 8px; left: 12px; letter-spacing: .6px; }
  #toolbar button { min-height: 30px; }
  #chatLog, #chatBar { width: min(290px, calc(100vw - 108px)); }
  #chatLog { max-height: 116px; padding: 7px 9px; font-size: 10px; }
  #chatInput { padding: 9px 8px; font-size: 11px; }
  #chatSend { font-size: 10px; padding: 7px; }
  .panel { max-height: 87vh; max-width: 94vw; }
  .panel-body { padding: 12px; }
  .panel-head { min-height: 48px; font-size: 13px; padding: 9px 12px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
  .map-grid { grid-template-columns: 1fr; }
  #wardrobePreview { gap: 8px; }
  #wardrobePreview .left { flex-basis: 110px; }
  #editHint { top: 111px; padding: 8px 10px; font-size: 9px; max-width: calc(100vw - 120px); }
  #toast { top: 110px; font-size: 11px; padding: 9px 12px; }
  #fishBtn { right: 11px; bottom: 15px; font-size: 12px; padding: 11px 14px; }
  #photoBar { max-width: 94vw; gap: 6px; padding: 7px; }
  #photoBar button.px { font-size: 11px; padding: 9px; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Reference-style window chrome: compact corners, a fine dark outline, no blur. */
body { background: #161b1b; }
button.px, .pixel-box, .panel, .hud-chip, #toolbar, #chatLog, #chatBar input,
.map-card, .item-card, .quest-card, .bag-info, .npc-dialog, .diary-card,
.trade-side, .stock-list, .dm-log, #ctxMenu, #photoBar, #editHint, #toast {
  border-radius: 2px; box-shadow: none;
}
button.px { border-color: #6b7063; background: #ece6cf; box-shadow: inset 1px 1px #fff9e7, inset -1px -1px #c3bba3; }
button.px:hover { border-color: #b99538; background: #f3e7b9; }
.pixel-box, #toolbar { border-color: #98702d; box-shadow: 0 0 0 1px #383b32, inset 0 0 0 2px #e7d7ae; }
.panel-head { background: #755b35; color: #fbf4d7; border-radius: 0; }
#mapName { background: #72562d; border-color: #b6964b; }
#toolbar { background: #ebe8d7; }
#toolbar::before { content: '奶糖小鎮'; color: #725b35; }
#toolbar::after { content: ''; }
#chatLog { background: #f1eee1e8; border-color: #9a947d; }
#login { background: #e8e6db; }
#login::before { display: none; }
.town-art-sun { display: none; }
.town-art { background: #161b1b; border: 1px solid #706c59; border-radius: 2px; }
.town-brand, #login h1 { color: #6c522c; }
.brand-candy { background: #ab7d2c; border-radius: 2px; transform: none; box-shadow: 2px 2px #443b28; }
#login .welcome-card { background: #f6f2e3; border-radius: 2px; }
#avatarPreview, .profile-head canvas { background: #dde0d3; border-radius: 2px; }
.avatar-turn-controls { display:flex; align-items:center; justify-content:center; gap:4px; margin-top:7px; font-size:10px; color:#725b35; white-space:nowrap; }
.avatar-turn-controls button.px { padding:3px 6px; min-width:24px; font-size:14px; }

#toggleToolbar, #viewControls { display: none; }
/* The fitting preview stays visible while only the clothing catalogue scrolls. */
#panelShop #shopContent { min-height: 0; overflow: hidden; }
#panelShop #shopBody { max-height: calc(84vh - 112px); }
#panelShop.shop-clothes { width: 780px; height: min(780px, 84vh); }
#panelShop.shop-clothes #shopContent { flex: 1; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
#panelShop.shop-clothes #shopBody { min-height: 0; max-height: none; }
#shopClothesPreview { padding: 12px 10px; background: #ebe8d7; border-right: 1px solid #c4bca4; text-align: center; overflow-y: auto; }
#shopClothesPreview[hidden] { display: none; }
#shopAvatarPreview { display: block; width: 180px; max-width: 100%; height: auto; margin: 0 auto; background: #dde0d3; border: 1px solid #aab299; image-rendering: pixelated; }
#shopClothesPreview h3 { margin: 12px 0 8px; font-size: 14px; color: #725b35; }
#shopTryName { min-height: 34px; line-height: 1.5; font-size: 12px; overflow-wrap: anywhere; }
#shopTryPrice { min-height: 22px; font-size: 13px; font-weight: bold; color: #876328; }
#shopClothesPreview p { margin: 10px 0 0; font-size: 10px; color: #77745d; line-height: 1.6; }
.shop-preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.shop-preview-actions button.px { min-width: 0; padding: 7px 4px; font-size: 11px; }
.shop-preview-actions button:disabled { cursor: default; opacity: .6; }
#panelShop .item-card.trying { border-color: #ad8534; background: #fff0c7; box-shadow: inset 0 0 0 1px #c9a559; }
#panelShop .item-card:focus-visible { outline: 2px solid #ad8534; outline-offset: 2px; }
.clothing-catalog-controls { position:sticky; top:-12px; z-index:2; padding:8px 0; background:#f6f2e3; border-bottom:1px solid #d3c7aa; }
.clothing-catalog-controls input { width:100%; min-height:32px; box-sizing:border-box; padding:6px 9px; background:#fffdf4; border:1px solid #aaa38c; color:#514936; font:inherit; font-size:12px; }
.clothing-catalog-tabs { display:flex; flex-wrap:wrap; gap:4px; margin-top:7px; }
.clothing-catalog-tabs button.px { min-width:0; padding:5px 8px; font-size:11px; }
.clothing-catalog-tabs button.on { background:#e6ce8d; border-color:#967331; }
.clothing-catalog-count { margin-top:6px; color:#827352; font-size:11px; }
.clothing-catalog-group[hidden], .item-card[hidden] { display:none !important; }
.clothing-new-label { display:block; color:#856631; font-size:9px; line-height:1.4; }
.clothing-catalog-group .section-title { margin-top:14px; }
#wardrobePreview .left { position:sticky; top:0; align-self:flex-start; }
#wardrobePreview .right { min-width:0; }
@media (max-width: 749px) {
  #panelShop.shop-clothes { height: 87vh; }
  #panelShop.shop-clothes #shopContent { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #shopClothesPreview { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-right: 0; border-bottom: 1px solid #c4bca4; overflow: visible; }
  #shopClothesPreview .shop-preview-picture { flex: 0 0 110px; min-width: 0; }
  #shopAvatarPreview { width: 110px; }
  #shopClothesPreview .shop-preview-details { flex: 1; min-width: 0; text-align: left; }
  #shopClothesPreview h3 { margin: 0 0 5px; font-size: 13px; }
  #shopTryName { min-height: 36px; font-size: 11px; }
  #shopClothesPreview p { margin-top: 7px; font-size: 9px; }
  #shopClothesPreview .avatar-turn-controls { margin-top: 4px; }
  #shopClothesPreview .avatar-turn-controls button { min-width: 26px; min-height: 26px; }
  #panelShop #shopBody { max-height: calc(87vh - 112px); }
}
.game-active #viewControls { display: flex; position: fixed; right: 20px; bottom: 20px; z-index: 22; gap: 3px; }
@media (max-width: 749px) {
  .game-active #toggleToolbar { display: block; position: fixed; right: 11px; top: 11px; z-index: 31; min-height: 34px; padding: 6px 10px; font-size: 11px; }
  .game-active #toolbar { display: none !important; top: 52px; width: 196px; grid-template-columns: 1fr 1fr; padding: 27px 8px 9px; border-radius: 2px; z-index: 30; }
  .game-active #toolbar.is-open { display: grid !important; }
  .game-active #viewControls { right: 11px; bottom: 12px; gap: 2px; }
  #viewControls button { min-width: 29px; min-height: 30px; padding: 4px 6px; font-size: 10px; }
  #chatLog { width: min(290px, calc(100vw - 22px)); bottom: 62px; max-height: 92px; }
  #chatBar { width: calc(100vw - 140px); }
  #chatBar #chatInput { min-width: 0; width: 100%; }
  #chatBar #chatSend { font-size: 10px; padding: 4px 6px; }
  #fishBtn { bottom: 53px; }
}

/* Readable type is shared across desktop and touch screens. Reflow the paper
   panels around the text instead of shrinking labels to fit small screens. */
body { font-size: var(--ui-text); line-height: 1.5; }
button, input, select, textarea { font-family: inherit; }
button.px, button.px.small { min-height: 42px; padding: 8px 12px; font-size: var(--ui-text); line-height: 1.35; }
button.px.tiny { min-height: 34px; padding: 5px 8px; font-size: var(--ui-small); }
button.px.big { min-height: 48px; font-size: 18px; }
input, select, textarea { font-size: var(--ui-text); line-height: 1.5; }
.panel input, .panel select, .panel textarea { max-width: 100%; font-size: var(--ui-text) !important; }
.panel input:not([type=checkbox]):not([type=radio]):not([type=range]), .panel select { min-height: 42px; }
/* Older dialogs author their short hints inline; keep those readable too. */
.panel :is([style*="font-size:9px"], [style*="font-size:10px"], [style*="font-size:11px"], [style*="font-size:12px"], [style*="font-size:13px"], [style*="font-size:14px"], [style*="font-size:15px"], [style*="font-size: 9px"], [style*="font-size: 10px"], [style*="font-size: 11px"], [style*="font-size: 12px"], [style*="font-size: 13px"], [style*="font-size: 14px"], [style*="font-size: 15px"]) { font-size: var(--ui-small) !important; line-height: 1.6; }
.panel button.px:not(.tiny) { font-size: var(--ui-text) !important; }

.welcome-header { min-height: 96px; flex-shrink: 0; }
.town-brand { font-size: 26px; letter-spacing: 2px; }
.town-brand small, .welcome-tag, .welcome-eyebrow, .welcome-card-label, .town-art-caption, .town-art-note { font-size: var(--ui-small); }
.town-brand small { letter-spacing: 2px; }
.welcome-main { grid-template-columns: minmax(0, 1fr) 440px; gap: clamp(28px, 4vw, 70px); padding: 32px 0; }
#login h1 { font-size: clamp(40px, 4vw, 56px); line-height: 1.3; margin-bottom: 18px; }
.welcome-description { font-size: 18px; line-height: 1.8; }
#login .welcome-card { padding: 28px 34px 30px; }
.welcome-card h2 { font-size: 32px; margin: 6px 0 18px; }
#login .welcome-card .sub, .login-tip { font-size: var(--ui-small); color: #68725e; line-height: 1.7; }
.login-label { font-size: 18px; line-height: 1.5; margin-bottom: 8px; color: #4e604e; }
.login-label span { font-size: var(--ui-small); }
#login input { min-height: 50px; height: auto; padding: 11px 13px; font-size: 18px; line-height: 1.5; margin-bottom: 18px; }
#login input::placeholder { font-size: 16px; color: #7a856e; }
#loginErr { min-height: 24px; font-size: var(--ui-text); line-height: 1.5; }
#login #loginBtn { min-height: 52px; height: auto; font-size: 18px; padding: 12px; letter-spacing: 1px; }
.welcome-card-foot, .welcome-card-foot span, .welcome-footer, .welcome-footer > span:last-child { font-size: var(--ui-small); }
.welcome-footer { min-height: 68px; padding: 14px 0; color: #66715b; line-height: 1.8; flex-shrink: 0; }
#newCharacterSetup { min-width: 0; margin-top: 16px; font-size: var(--ui-text); text-align: left; }
#newCharacterSetup[hidden] { display: none !important; }
#newCharacterSetup h3 { font-size: var(--ui-title); line-height: 1.4; margin: 0 0 12px; }
#newCharacterSetup label, #newCharacterSetup legend { font-size: var(--ui-text); }
#newCharacterSetup button { min-height: 44px; font-size: var(--ui-text); }
#newCharacterSetup :is(.gender-options, .gender-choices, .starter-choices) { display: flex; flex-wrap: wrap; gap: 10px; }
#newCharacterSetup :is(.gender-options, .gender-choices, .starter-choices) > * { flex: 1; min-width: 100px; }
#newCharacterSetup canvas { display: block; max-width: 100%; height: auto; margin: 8px auto; }
#newCharacterSetup { border: 1px solid #c4bca4; padding: 12px; margin-bottom: 18px; }
#newCharacterSetup legend { padding: 0 6px; font-size: 18px; font-weight: 700; color: #725b35; }
#newCharacterSetup > p { margin: 0 0 12px; font-size: 14px; line-height: 1.7; color: #68725e; }
.starter-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#newCharacterSetup .starter-option { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; padding: 10px 7px; border: 1px solid #aaa38c; border-radius: 3px; background: #fffdf4; color: #514936; font-size: 14px; line-height: 1.5; cursor: pointer; }
#newCharacterSetup .starter-option strong { font-size: 18px; }
#newCharacterSetup .starter-option > span:last-child { font-size: 14px; }
#newCharacterSetup .starter-option[aria-pressed=true] { border-color: #967331; background: #f3e7b9; outline: 2px solid #b99538; outline-offset: 1px; }
#newCharacterSetup .starter-option:focus-visible { outline: 3px solid #d89958; outline-offset: 2px; }
.starter-picture { display: block; width: 90px; max-width: 100%; }
.starter-picture canvas { width: 90px; max-width: 100%; }

#hud { max-width: calc(100vw - 310px); gap: 7px; }
.hud-chip { min-height: 40px; padding: 8px 10px; font-size: var(--ui-text); line-height: 1.35; }
.hud-chip.dim { font-size: var(--ui-small); }
#mapName { font-size: 18px; padding: 9px 13px; }
#bgmBtn { min-height: 40px; }
#toolbar { width: 260px; padding: 42px 10px 12px; gap: 8px; max-height: calc(100dvh - 36px); overflow-y: auto; }
#toolbar::before { font-size: var(--ui-small); top: 13px; }
#toolbar button { min-height: 44px; min-width: 0; font-size: var(--ui-text); padding: 9px 6px; white-space: normal; }
#chatLog { width: 390px; max-height: 190px; padding: 10px 13px; font-size: var(--ui-text); line-height: 1.65; overflow-wrap: anywhere; bottom: 78px; }
#chatLog .sys { font-size: var(--ui-small); }
#chatBar { width: 390px; align-items: stretch; }
#chatInput { min-height: 44px; font-size: var(--ui-text); padding: 9px 12px; }
#chatSend { flex-shrink: 0; min-height: 44px; font-size: var(--ui-text); }
#viewControls button { min-height: 44px; min-width: 42px; font-size: var(--ui-text); }

.panel { width: 700px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 40px); font-size: var(--ui-text); }
.panel.narrow { width: 540px; }
.panel.wide { width: 900px; }
.panel-head { min-height: 62px; gap: 12px; padding: 12px 16px; font-size: var(--ui-title); line-height: 1.35; }
.panel-head > span { min-width: 0; overflow-wrap: anywhere; }
.panel-head > .danger { flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 18px; }
.panel-body { min-height: 0; overflow: auto; padding: 18px; overscroll-behavior: contain; }
.tabs { flex-shrink: 0; gap: 8px; padding: 12px 18px 0; }
.tabs .px { min-height: 42px; font-size: var(--ui-text); padding: 8px 13px; }
.item-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.item-card { min-width: 0; padding: 12px 8px 10px; font-size: var(--ui-text); line-height: 1.5; overflow-wrap: anywhere; }
.item-card .price { font-size: var(--ui-text); }
.item-card .tag { top: 5px; right: 5px; font-size: 12px; line-height: 1.5; }
.section-title { font-size: 18px; line-height: 1.5; margin: 18px 0 10px; }
.minitag, .attr-badge, .clothing-new-label { font-size: var(--ui-small); line-height: 1.5; }
.clothing-catalog-controls { top: -18px; padding: 10px 0; }
.clothing-catalog-controls input { min-height: 44px; font-size: var(--ui-text); padding: 9px 11px; }
.clothing-catalog-tabs { gap: 6px; margin-top: 9px; }
.clothing-catalog-tabs button.px { min-height: 38px; padding: 7px 10px; font-size: var(--ui-small); }
.clothing-catalog-count { font-size: var(--ui-small); line-height: 1.5; margin-top: 8px; }
.clothing-catalog-tabs button.on { color: #514936; }
.tabs .px { color: #5b6c4e; }
.item-card .price { color: #896329; }
.section-title { color: #66734f; }
.clothing-catalog-count { color: #6f6146; }
.clothing-new-label { color: #725a2a; }
.hud-chip.dim, #chatLog .sys, .bag-info, .game-hint { color: #65715a; }
.swatches { gap: 8px; }
.swatch { width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; }
.player-row, .map-card-name, .quest-card, .bag-info, .stock-row, .dm-log, .diary-card, .diary-comment, .trade-item, .profile-info, .ab-line, .game-info { font-size: var(--ui-text); line-height: 1.65; }
.bank-est, .stock-hold, .diary-comments-head, .trade-side-head, .game-hint, .bt-seat, .holdem-p-name, .fm-title { font-size: var(--ui-small); line-height: 1.5; }
.npc-dialog { font-size: 18px; line-height: 1.75; }
.game-status { font-size: 20px; }
.stock-detail, .trade-side, .dm-input, .profile-head { min-width: 0; }
.player-row { flex-wrap: wrap; gap: 10px; }
.card-btns, .quest-btns, .dm-input { flex-wrap: wrap; }
.dm-input input { min-width: 140px; }
.diary-title, .diary-text, .dm-input input { font-size: var(--ui-text); }
#ctxMenu { width: min(230px, calc(100vw - 24px)); }
#ctxMenu .ctx-name { font-size: 18px; }
#ctxMenu button, #editHint, #toast, #photoBar button.px { font-size: var(--ui-text); }
#editHint { max-width: min(680px, calc(100vw - 32px)); line-height: 1.65; }
#editStatus { display: block; font-size: 18px; line-height: 1.4; }
#editSteps { font-size: 14px; margin-top: 5px; }
#editActions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
#editActions button.px { min-height: 44px; font-size: 16px; }
body:has(#editHint.show) #chatLog { display: none !important; }
#toast { max-width: calc(100vw - 32px); line-height: 1.6; text-align: center; }
#photoBar { max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
#photoBar button.px { white-space: normal; }
#adBanner { font-size: 22px; }
#adBanner .ad-from { font-size: var(--ui-small); }
.sticker-lv { font-size: 12px; }
.boat-card { max-width: calc(100vw - 24px); padding: 24px; font-size: 24px; }

#wardrobePreview { gap: 18px; }
#wardrobePreview .left { flex-basis: 150px; }
#wardrobePreview .left > div:last-child { font-size: var(--ui-small) !important; line-height: 1.6; }
.avatar-turn-controls { gap: 7px; font-size: var(--ui-small); white-space: normal; flex-wrap: wrap; }
.avatar-turn-controls button.px { min-width: 40px; min-height: 40px; padding: 5px 9px; font-size: 20px; }
#panelShop.shop-clothes { width: 940px; height: min(850px, calc(100dvh - 40px)); }
#panelShop.shop-clothes #shopContent { grid-template-columns: 260px minmax(0, 1fr); min-height: 0; }
#panelShop #shopBody { max-height: calc(100dvh - 170px); }
#panelShop.shop-clothes #shopBody { max-height: none; }
#shopClothesPreview { min-height: 0; padding: 14px; overscroll-behavior: contain; }
#shopAvatarPreview { width: 190px; }
#shopClothesPreview h3 { font-size: 22px; line-height: 1.4; margin: 12px 0 8px; }
#shopTryName { min-height: 48px; font-size: var(--ui-text); line-height: 1.5; }
#shopTryPrice { min-height: 26px; font-size: 18px; line-height: 1.5; }
#shopClothesPreview p { font-size: var(--ui-small); color: #62644f; line-height: 1.6; }
.shop-preview-actions { gap: 8px; }
.shop-preview-actions button.px { min-height: 44px; font-size: var(--ui-text); padding: 8px 5px; }
#shopTryColors { margin: 10px 0 12px; text-align: left; }
#shopTryColors[hidden] { display: none !important; }
#shopTryColorLabel { display: block; margin-bottom: 6px; font-size: var(--ui-small); font-weight: 700; }
.shop-color-choice { display: flex; gap: 8px; align-items: center; min-width: 0; }
#shopTryColorSwatch { flex: 0 0 32px; height: 32px; border: 1px solid #746e5d; border-radius: 3px; }
#shopTryColorSelect { min-width: 0; width: 100%; min-height: 42px; padding: 7px 8px; border: 1px solid #aaa38c; background: #fffdf4; color: #514936; font-size: var(--ui-text); }

/* The same readable controls cover keyboard games when played by touch. */
#gameBody canvas { max-width: 100%; height: auto; }
#gameBody button.px, #rpsBody button.px { min-height: 44px; }
.game-status.winflash { animation: game-result-pop .35s; }
@keyframes game-result-pop { from { transform: scale(.94); opacity: .5; } to { transform: scale(1); opacity: 1; } }
#gameBody button.rou-cell { color: #fffdf5; }
#gameBody button.rc-bin { color: #fffdf5; }
#gameBody button.rc-bin:first-child { color: #334342; text-shadow: none; }
#gameBody button.rc-bin:nth-child(2) { background: #2678ad !important; }
#gameBody button.rc-bin:nth-child(4) { background: #607375 !important; }
.gomoku-board { grid-template-columns: repeat(13, minmax(0, 1fr)); width: min(100%, 364px); }
.gomoku-cell { min-width: 0; width: 100%; height: auto; aspect-ratio: 1; }
.bt-card.big { min-width: 44px; min-height: 44px; }
#gameBody .game-info:has(.bt-seat) { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#gameBody .game-info .bt-seat { display: inline-block; max-width: 100%; margin: 0; overflow-wrap: anywhere; }
.minigame-touch-controls { display: grid; grid-template-columns: repeat(3, minmax(44px, 1fr)); grid-template-areas: 'label label label' '. up .' 'left down right'; gap: 6px; width: min(240px, 100%); margin: 12px auto; padding: 10px; background: #f6f2e3; border: 1px solid #c4bca4; touch-action: none; }
.minigame-touch-label { grid-area: label; font-size: 14px; line-height: 1.5; text-align: center; color: #5d674f; }
.panel button.minigame-touch-key.px { min-width: 44px; min-height: 46px; padding: 7px; font-size: 22px !important; touch-action: none; }
.minigame-touch-key.touch-up { grid-area: up; }
.minigame-touch-key.touch-down { grid-area: down; }
.minigame-touch-key.touch-left { grid-area: left; }
.minigame-touch-key.touch-right { grid-area: right; }
.minigame-touch-key.is-held, .minigame-touch-key[aria-pressed=true] { background: var(--teal); color: #fffdf3; border-color: var(--teal-deep); box-shadow: inset 0 0 0 1px #ffffff55; }
#ddrTouchControls { grid-template-columns: repeat(4, minmax(44px, 1fr)); grid-template-areas: 'label label label label' 'left down up right'; width: min(420px, 100%); }
.minigame-dual-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; min-width: 0; margin: 10px 0; }
.minigame-dual-controls .minigame-touch-controls { min-width: 0; width: 100%; margin: 0; padding: 7px; gap: 4px; }
.panel .minigame-dual-controls button.minigame-touch-key.px { font-size: 16px !important; padding: 7px 3px; }
.minigame-readout { padding: 10px 12px; margin: 8px 0; background: #f2f4e3; border: 1px solid #c4bca4; font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.pool-shot-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
.pool-shot-controls label { flex: 1; min-width: 150px; font-size: 16px; }
#poolPower { width: 100%; min-height: 44px; touch-action: pan-x; }
#poolShoot { min-width: 120px; min-height: 44px; font-size: 16px; }
#poolScore > span:first-child { color: #926319 !important; }
#poolScore > span:nth-child(2) { color: #26718b !important; }
#dwTools .dw-color { flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; }
#dwTools > button.px { min-height: 44px; }

@media (min-width: 1600px) {
  .welcome-main { grid-template-columns: minmax(0, 1fr) 460px; }
}
@media (max-width: 1050px) and (min-width: 750px) {
  .welcome-main { grid-template-columns: minmax(0, 1fr) 400px; gap: 26px; }
  #login h1 { font-size: 40px; }
}
@media (max-width: 749px) {
  #login { padding: 0 18px; }
  .welcome-header { min-height: 80px; }
  .town-brand { font-size: 24px; }
  .town-brand small { font-size: 14px; letter-spacing: 2px; }
  .welcome-main { display: flex; flex-direction: column; width: min(100%, 440px); gap: 20px; padding: 22px 0; flex: 0 0 auto; }
  .welcome-world { width: 100%; text-align: center; }
  #login h1 { display: block; font-size: 34px; letter-spacing: 1px; margin: 0 0 14px; }
  .welcome-description { font-size: 16px; }
  .town-art { height: 180px; margin: 0; }
  .town-art-note, .town-art-caption { font-size: 14px; letter-spacing: 0; }
  #login .welcome-card { max-width: none; padding: 24px; }
  .welcome-avatar { display: none; }
  .welcome-card h2 { font-size: 28px; margin: 0 0 14px; }
  .welcome-footer { min-height: 76px; font-size: 14px; padding: 14px 0; text-align: center; justify-content: center; }
  #hud { top: 10px; left: 10px; max-width: calc(100vw - 110px); gap: 5px; }
  .hud-chip { min-height: 34px; padding: 6px 8px; font-size: 14px; }
  .hud-chip.dim { font-size: 14px; }
  #mapName { font-size: 16px; padding: 7px 10px; }
  .game-active #toggleToolbar { top: 10px; right: 10px; min-height: 44px; font-size: 16px; padding: 9px 12px; }
  .game-active:has(.panel.show) #toggleToolbar, .game-active:has(.panel.show) #toolbar { display: none !important; }
  .game-active #toolbar { top: 62px; right: 10px; width: min(264px, calc(100vw - 20px)); padding: 40px 10px 10px; gap: 8px; max-height: calc(100dvh - 140px); }
  #toolbar::before { left: 12px; top: 13px; font-size: 14px; }
  #toolbar button { min-height: 44px; font-size: 16px; padding: 8px 5px; }
  #chatLog { left: 10px; width: calc(100vw - 20px); bottom: 70px; max-height: 124px; padding: 8px 10px; font-size: 16px; }
  #chatBar { left: 10px; bottom: 12px; width: calc(100vw - 158px); gap: 6px; }
  #chatBar #chatInput { min-width: 0; min-height: 44px; padding: 8px; font-size: 16px; }
  #chatBar #chatSend { min-height: 44px; padding: 7px 8px; font-size: 16px; }
  .game-active #viewControls { right: 10px; bottom: 12px; gap: 3px; }
  #viewControls button { min-width: 40px; min-height: 44px; padding: 7px 8px; font-size: 14px; }
  .panel { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .panel-head { min-height: 60px; padding: 10px 12px; font-size: 22px; }
  .panel-body { padding: 12px; }
  .tabs { gap: 7px; padding: 10px 12px 0; }
  .tabs .px { font-size: 16px; padding: 8px 10px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .map-grid { grid-template-columns: 1fr; }
  .clothing-catalog-controls { top: -12px; }
  .clothing-catalog-tabs button.px { min-height: 38px; padding: 7px 9px; font-size: 14px; }
  #wardrobePreview { gap: 12px; }
  #wardrobePreview .left { flex-basis: 118px; }
  #wardrobePreview .left .avatar-turn-controls > span { flex-basis: 100%; order: -1; }
  #avatarPreview { max-width: 100%; }
  #panelShop.shop-clothes { height: calc(100dvh - 20px); }
  #panelShop.shop-clothes #shopContent { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #shopClothesPreview { display: flex; align-items: flex-start; gap: 12px; max-height: min(34dvh, 300px); overflow-y: auto; padding: 12px; }
  #shopClothesPreview .shop-preview-picture { flex: 0 0 104px; position: sticky; top: 0; }
  #shopAvatarPreview { width: 104px; }
  #shopClothesPreview .shop-preview-details { flex: 1; min-width: 0; }
  #shopClothesPreview h3 { margin: 0 0 8px; font-size: 20px; }
  #shopTryName { min-height: 24px; font-size: 16px; }
  #shopTryPrice { font-size: 18px; }
  #shopClothesPreview p { margin-top: 8px; font-size: 14px; }
  #shopClothesPreview .avatar-turn-controls { gap: 5px; margin-top: 7px; }
  #shopClothesPreview .avatar-turn-controls > span { flex-basis: 100%; order: -1; }
  #shopClothesPreview .avatar-turn-controls button { min-width: 40px; min-height: 40px; }
  #shopTryColors { margin: 8px 0 10px; }
  .shop-preview-actions { grid-template-columns: 1fr 1fr; gap: 7px; }
  #panelShop #shopBody { max-height: none; }
  #editHint { top: auto; bottom: 70px; max-width: calc(100vw - 24px); width: 560px; max-height: 34dvh; overflow-y: auto; padding: 10px 12px; font-size: 14px; }
  #editActions { gap: 7px; }
  #editActions button.px { flex: 1 1 130px; min-width: 0; padding: 8px; }
  #toast { top: 152px; font-size: 16px; padding: 10px 12px; }
  #photoBar { bottom: 68px; padding: 8px; }
  #fishBtn { right: 10px; bottom: 68px; font-size: 16px; min-height: 44px; padding: 10px 12px; }
  .stock-wrap, .trade-wrap { flex-wrap: wrap; }
  .profile-head { flex-wrap: wrap; }
  .bank-row { flex-wrap: wrap; }
}
@media (max-height: 620px) {
  .welcome-header { min-height: 72px; }
  .welcome-main { align-items: start; padding-top: 20px; padding-bottom: 24px; }
  #login h1 { font-size: 38px; }
  .welcome-description { font-size: 16px; }
  .welcome-avatar { display: none; }
  .town-art { height: 230px; }
  .panel { max-height: calc(100dvh - 16px); }
  .panel-head { min-height: 54px; font-size: 22px; padding-top: 8px; padding-bottom: 8px; }
  #panelShop.shop-clothes { height: calc(100dvh - 16px); }
  #shopClothesPreview { max-height: none; }
  .clothing-catalog-controls { position: static; }
  #gameBody > .minigame-touch-controls, #gameBody > .minigame-dual-controls { position: sticky; bottom: -18px; z-index: 3; box-shadow: 0 -5px 12px #33434222; }
  .minigame-dual-controls .minigame-touch-controls { position: static; box-shadow: none; }
  #chatLog { max-height: 96px; }
}
@media (max-height: 620px) and (max-width: 749px) {
  #shopClothesPreview { max-height: 34dvh; }
}
@media (max-height: 620px) and (min-width: 640px) {
  #panelGame:has(#i2Canvas, #dsCanvas, #poolCanvas, #ddrTouchControls) { width: calc(100vw - 16px); max-width: 1100px; }
  #gameBody:has(#i2Canvas, #dsCanvas, #poolCanvas, #ddrTouchControls) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 8px 12px; padding: 12px; }
  #gameBody:has(#i2Canvas, #dsCanvas, #poolCanvas, #ddrTouchControls) > .game-status { grid-column: 1 / -1; grid-row: 1; margin: 0; font-size: 18px; line-height: 1.4; }
  #gameBody:has(#i2Canvas, #dsCanvas, #poolCanvas) > canvas { grid-column: 1; grid-row: 2 / span 3; align-self: center; width: 100%; max-width: 100%; height: auto; margin: 0; }
  #gameBody:has(#i2Canvas, #dsCanvas, #poolCanvas, #ddrTouchControls) > .game-hint { grid-column: 2; grid-row: 2; margin: 0; }
  #gameBody:has(#i2Canvas, #dsCanvas, #ddrTouchControls) > .minigame-touch-controls,
  #gameBody:has(#i2Canvas, #dsCanvas, #ddrTouchControls) > .minigame-dual-controls { grid-column: 2; grid-row: 3; position: static; width: 100%; margin: 0; box-shadow: none; }
  #gameBody:has(#i2Canvas) > .game-hint { display: none; }
  #i2Readout { grid-column: 2; grid-row: 2; margin: 0; padding: 6px 8px; font-size: 14px; line-height: 1.4; }
  #gameBody:has(#i2Canvas) > button { grid-column: 2; grid-row: 4; justify-self: start; }
  #gameBody:has(#poolCanvas) > .pool-shot-controls { grid-column: 2; grid-row: 3; margin: 0; }
  #gameBody:has(#poolCanvas) #poolPower { margin: 0; }
  #gameBody:has(#ddrTouchControls) > .ddr-stage { grid-column: 1; grid-row: 2 / span 3; height: clamp(170px, calc(100dvh - 150px), 280px); }
  #panelGame:has(#dwCanvas) { width: calc(100vw - 16px); max-width: 1100px; }
  #gameBody:has(#dwCanvas) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 8px 12px; padding: 12px; }
  #gameBody:has(#dwCanvas) > .game-info { display: none; }
  #gameBody:has(#dwCanvas) > .game-status { grid-column: 1 / -1; grid-row: 1; margin: 0; font-size: 16px; line-height: 1.5; }
  #dwCanvas { grid-column: 1; grid-row: 2 / span 3; width: min(100%, 380px); height: auto; margin: 0; }
  #dwTools, #dwGuessBar { grid-column: 2; grid-row: 2; margin: 0; }
  #gameBody:has(#dwCanvas) > .ab-feed { grid-column: 2; grid-row: 3; max-height: 140px; margin: 0; }
}
@media (max-width: 360px) {
  .minigame-dual-controls { grid-template-columns: 1fr; }
  .minigame-dual-controls .minigame-touch-controls { grid-template-columns: repeat(4, minmax(44px, 1fr)); grid-template-areas: 'label label label label' 'left down up right'; }
}
#stickerPicker.show { display: flex; }
#stickerPicker { width: min(386px, calc(100vw - 16px)); padding: 10px; gap: 8px; flex-direction: column; box-sizing: border-box; overflow: hidden; z-index: 46; }
.social-head, .social-tabs { display: flex; gap: 6px; align-items: center; }
.social-tabs { flex: 1; }
.social-head button { border: 1px solid #b8c4a8; border-radius: 8px; background: #f5f2df; color: #40533c; min-height: 44px; padding: 8px 12px; font: inherit; font-size: 16px; cursor: pointer; }
.social-tabs button[aria-selected="true"] { background: #506f48; border-color: #506f48; color: #fff; }
.social-close { min-width: 44px; }
.social-hint { color: #5a6951; font-size: 14px; margin: 0; }
.social-items { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.social-item { min-width: 0; min-height: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 3px; border: 1px solid #c6d0b8; border-radius: 9px; color: #40533c; background: #fffef7; cursor: pointer; font: inherit; }
.social-item:hover, .social-item:focus-visible { background: #ecf4d9; border-color: #708b57; }
.social-item:disabled { opacity: .55; cursor: default; }
.social-art { display: block; width: 60px; height: 60px; object-fit: contain; font-size: 34px; line-height: 60px; text-align: center; }
.social-label { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.social-action .social-art { height: 42px; line-height: 42px; }
.chat-sticker { display: inline-block; width: 88px; height: 88px; object-fit: contain; vertical-align: middle; margin: 3px 0; }
#facingToggle { position: fixed; left: 0; top: 0; z-index: 18; width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: #fff9dc; font-size: 18px; line-height: 40px; text-align: center; text-shadow: 0 1px 2px #253a27, 1px 0 2px #253a27, -1px 0 2px #253a27; cursor: pointer; touch-action: manipulation; }
#facingToggle:hover, #facingToggle:focus-visible { color: #ffe16c; border-radius: 50%; background: #405c4140; }
#facingToggle[hidden], #facingPicker[hidden] { display: none; }
#facingPicker { position: fixed; z-index: 47; width: 178px; padding: 10px; box-sizing: border-box; border: 1px solid #9aac88; border-radius: 12px; background: #fffdf0; box-shadow: 0 5px 22px #253c3233; text-align: center; color: #40533c; }
#facingPicker strong { font-size: 16px; }
.facing-directions { display: grid; grid-template-columns: repeat(3, 46px); gap: 5px; margin: 8px 0; justify-content: center; }
.facing-directions button { width: 46px; height: 44px; border: 1px solid #c3cdb2; border-radius: 7px; font-size: 22px; color: #40533c; background: #f4f5e8; cursor: pointer; }
.facing-directions button[aria-pressed="true"] { color: white; background: #58794e; }
.facing-directions button:disabled { opacity: .45; }
#facingPicker p { font-size: 14px; margin: 0; }
@media (pointer: coarse) { #facingToggle { width: 44px; height: 44px; line-height: 44px; } }
@media (max-height: 480px) { .social-items { grid-template-columns: repeat(6,minmax(0,1fr)); } .social-item { min-height: 72px; } .social-art { width: 42px; height: 42px; line-height: 42px; } #stickerPicker { width: min(570px,calc(100vw - 16px)); } }
.fixed-hair-note { display:flex; align-items:center; gap:8px; margin:8px 0; color:#685276; font-size:14px; line-height:1.5; padding:9px 11px; border:1px solid #d4c7d9; border-radius:8px; background:#f8f0f7; }
.fixed-hair-note[hidden] { display:none; }
.fixed-hair-chip { display:inline-block; width:26px; height:26px; flex:none; border-radius:50%; border:1px solid #a78eaf; }
.fixed-hair-tag { color:#776080; font-size:14px; margin-top:4px; }
