:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #293526;
  --muted: #6a705e;
  --paper: #fdfaf2;
  --line: #e6dfcf;
  --green: #365738;
  --sage: #e7eddf;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 35% 6%, #fffdf7 0%, #f7f3e9 58%, #eee8d8 100%); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid #587c52; outline-offset: 4px; }
[hidden] { display: none !important; }
.topbar, .layout { max-width: 1360px; margin-inline: auto; padding-inline: clamp(16px, 3.5vw, 48px); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 26px 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { display: grid; place-items: center; width: 44px; height: 44px; color: var(--green); border-radius: 14px; background: var(--sage); }
.brand-icon svg { width: 27px; height: 27px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(20px, 2.3vw, 28px); font-weight: 750; letter-spacing: .04em; }
h2 { font-size: 17px; font-weight: 730; letter-spacing: .03em; }
.mode { display: flex; gap: 7px; align-items: center; color: #55684f; font-size: 12px; font-weight: 650; border: 1px solid #dce4d3; background: #eff3e9; border-radius: 999px; padding: 7px 12px; white-space: nowrap; }
.mode span { width: 7px; height: 7px; border-radius: 50%; background: #7b9b66; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(248px, 28%); gap: 20px; padding-bottom: 32px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: 0 10px 30px #6b532112; }
.room { overflow: hidden; }
.room-header, .focus-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.room-header { padding: 14px 18px; }
.availability { color: var(--muted); font-size: 12px; font-weight: 630; }
.scene { aspect-ratio: 3 / 2; position: relative; isolation: isolate; overflow: hidden; background: #d9b583 center / 100% 100% no-repeat; }
canvas { display: block; width: 100%; height: 100%; }
.player-tag, .seat-prompt { position: absolute; z-index: 1; inset: 0 auto auto 0; translate: -50% -100%; white-space: nowrap; }
.player-tag { pointer-events: none; border-radius: 999px; padding: 3px 7px; color: #29442c; font-size: 11px; line-height: 1; font-weight: 750; background: #f7ffec; box-shadow: 0 2px 7px #38261339; }
.seat-prompt { display: flex; gap: 6px; align-items: center; border: 1px solid #fcf8ea; padding: 5px 10px 5px 6px; border-radius: 9px; color: #fffdf5; background: #28442e; box-shadow: 0 4px 12px #1b28194d; font-size: 12px; font-weight: 650; }
.seat-prompt kbd { color: #28442e; background: #f4f8e9; border-color: transparent; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 16px; min-height: 52px; color: var(--muted); font-size: 12px; }
.key-guide { display: flex; align-items: center; gap: 5px; }
kbd { background: #f4efe3; border: 1px solid #e5deca; border-radius: 5px; padding: 2px 5px; font-family: inherit; font-size: 11px; line-height: 1.2; font-weight: 650; white-space: nowrap; }
.separator { height: 14px; border-left: 1px solid var(--line); margin-inline: 5px; }
.touch-pad { display: none; gap: 5px; }
.touch-pad button { width: 38px; height: 36px; touch-action: none; user-select: none; border: 1px solid var(--line); border-radius: 8px; background: #f3eee2; font-weight: 700; }
.touch-pad button:active { background: var(--sage); }
.focus { padding: clamp(16px, 2vw, 24px); }
.status { color: #58614e; background: #efeddf; padding: 5px 8px; border-radius: 6px; font-size: 11px; white-space: nowrap; }
.status[data-state="running"], .status[data-state="done"] { color: var(--green); background: var(--sage); }
.clock { position: relative; width: min(83%, 210px); aspect-ratio: 1; margin: 28px auto 24px; display: grid; place-items: center; }
.clock svg { position: absolute; inset: 0; width: 100%; fill: none; stroke-width: 5; rotate: -90deg; }
.clock-track { stroke: #e7e4d6; }
.clock-ring { stroke: #7a956b; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.clock-text { text-align: center; display: grid; gap: 4px; }
#time { font: 680 clamp(36px, 4.3vw, 61px)/1.1 system-ui, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.06em; }
#clock-caption { color: var(--muted); font-size: 12px; }
.durations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.durations button { border: 1px solid var(--line); border-radius: 8px; background: transparent; padding: 7px 2px; font-size: 12px; white-space: nowrap; }
.durations button[aria-pressed="true"] { background: var(--sage); color: var(--green); border-color: #c7d4bd; font-weight: 700; }
.durations button:disabled { opacity: .75; }
.start { border: 0; width: 100%; margin-top: 15px; padding: 12px 8px; border-radius: 10px; background: var(--green); color: white; font-size: 14px; font-weight: 700; }
.start:hover:not(:disabled) { background: #2a492d; }
.start:disabled { background: #e7e9dc; color: #656f5d; }
.timer-note { margin-top: 11px; min-height: 36px; color: var(--muted); line-height: 1.55; font-size: 12px; }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .topbar { padding-block: 16px; }
  .focus { max-width: 460px; width: 100%; justify-self: center; }
  .clock { width: min(54%, 175px); margin-block: 14px; }
  #time { font-size: clamp(34px, 8vw, 52px); }
}
@media (pointer: coarse) {
  .touch-pad { display: flex; }
  .key-guide { display: none; }
  .seat-prompt { min-height: 34px; }
}
@media (max-width: 370px) {
  .controls { padding-inline: 8px; }
  #room-note { text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  .clock-ring { transition: none; }
}

.brand { color: inherit; text-decoration: none; }
.brand-title { font-size: clamp(20px, 2.3vw, 28px); font-weight: 750; letter-spacing: .04em; }
.session-link { color: var(--green); border: 1px solid #dce4d3; background: #eff3e9; padding: 8px 12px; border-radius: 9px; font-size: 13px; text-decoration: none; font-weight: 650; }
.session-link:hover { background: #e5eddd; }
.lobby { max-width: 1360px; margin: auto; padding: 36px clamp(16px, 3.5vw, 48px) 56px; }
.lobby-heading { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: end; gap: 16px; margin-bottom: 28px; }
.lobby-heading h1 { font-size: clamp(30px, 4.6vw, 54px); letter-spacing: .025em; }
.lobby-heading p { color: var(--muted); margin-top: 10px; line-height: 1.6; font-size: 14px; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lobby-room { overflow: hidden; }
.room-cover { aspect-ratio: 1.68; background: #cba778 center 48% / cover no-repeat; }
.lobby-room-content { padding: 18px; }
.room-name-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-remaining { border-radius: 999px; background: var(--sage); color: var(--green); padding: 5px 9px; white-space: nowrap; font-weight: 730; font-size: 12px; }
.full .room-remaining { color: #725d4b; background: #eee4d9; }
.room-total { color: var(--muted); font-size: 13px; margin: 8px 0 16px; }
.room-entry { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 9px; background: var(--green); color: #fffdf7; text-decoration: none; font-size: 13px; font-weight: 690; }
.room-entry:hover { background: #2a492d; }
.room-entry[aria-disabled="true"] { background: #e9e8df; color: #6a705e; }
:is(.room-entry, .session-link):focus-visible { outline: 2px solid #587c52; outline-offset: 3px; }
@media (max-width: 760px) {
  .lobby { padding-top: 16px; }
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .room-grid { grid-template-columns: 1fr; }
}

.setup { max-width: 1050px; padding: 12px clamp(16px, 4vw, 48px) 40px; margin-inline: auto; }
.setup-steps { display: flex; align-items: center; gap: 8px; margin: 8px 0 21px; padding: 0; list-style: none; }
.setup-steps li { padding: 6px 11px; border-radius: 999px; color: var(--muted); font-size: 13px; }
.setup-steps [aria-current="step"] { background: var(--sage); color: var(--green); font-weight: 730; }
.setup-name { display: grid; grid-template-columns: 1.12fr 1fr; max-width: 760px; overflow: hidden; }
.setup-name-content { padding: clamp(22px, 4vw, 38px); }
.setup :is(h1) { font-size: clamp(26px, 4vw, 36px); line-height: 1.28; }
.setup h1:focus { outline: none; }
.setup :is(h1 + p) { color: var(--muted); font-size: 14px; margin-top: 9px; line-height: 1.55; }
.setup-name label { display: block; margin: 26px 0 7px; font-size: 14px; font-weight: 700; }
.setup-name input { width: 100%; min-height: 45px; border: 1px solid #ccc5b5; border-radius: 9px; padding: 9px 12px; font: inherit; background: #fffdf8; color: var(--ink); }
.setup-name input:focus-visible, .avatar-filters button:focus-visible { outline: 2px solid #6c8a5a; outline-offset: 2px; }
.setup-hint { display: block; margin-top: 7px; font-size: 12px; color: var(--muted); }
.setup-illustration { min-height: 280px; display: grid; place-items: center; background: radial-gradient(ellipse,#faf6df 10%,#e3ebdb 88%); border-left: 1px solid var(--line); }
.setup-illustration .avatar-art { width: min(85%, 260px); }
.setup-avatar-heading { display: flex; gap: 14px; justify-content: space-between; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.avatar-filters { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.avatar-filters button { padding: 5px 9px; border: 0; border-radius: 7px; background: transparent; font-size: 12px; font-weight: 650; }
.avatar-filters [aria-pressed="true"] { background: var(--sage); color: var(--green); }
.avatar-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.avatar-card { --accent: #745477; --tone: #f0e8ef; position: relative; display: grid; justify-items: center; cursor: pointer; border: 2px solid var(--line); border-radius: 14px; padding: 7px 6px 10px; background: radial-gradient(ellipse at center,#fffaf0,var(--tone)); }
.avatar-card[data-avatar-group="NF"] { --accent: #42654b; --tone: #e9eddf; }
.avatar-card[data-avatar-group="SJ"] { --accent: #3b6578; --tone: #e7eef3; }
.avatar-card[data-avatar-group="SP"] { --accent: #895b38; --tone: #f5e5d3; }
.avatar-card:hover { border-color: var(--accent); }
.avatar-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.avatar-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.avatar-art { display: block; aspect-ratio: 1; width: min(100%, 116px); background: url('/assets/mbti-portraits.webp') var(--portrait-x,0%) var(--portrait-y,0%) / 400% 400% no-repeat; }
.avatar-code { font: 750 13px/1.2 system-ui,sans-serif; color: var(--accent); letter-spacing: .08em; }
.setup-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.setup-actions .start { margin: 0; width: auto; padding: 10px 17px; }
.setup-actions .setup-hint { margin: 0; }
.setup-error { margin-top: 13px; color: #8c3d34; font-size: 13px; }
.account-actions { display: flex; align-items: center; gap: 8px; }
.account-name { max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 720; color: var(--green); font-size: 13px; }
.player-tag { max-width: 13ch; overflow: hidden; text-overflow: ellipsis; }
.occupant-tag { background: #fffaec; color: #4b3823; }
@media (max-width: 575px) {
  .setup-name { grid-template-columns: 1fr; }
  .setup-illustration { grid-row: 1; min-height: 116px; border: 0; border-bottom: 1px solid var(--line); }
  .setup-illustration .avatar-art { width: 113px; }
  .avatar-grid { gap: 7px; }
  .avatar-card { padding: 4px 3px 7px; border-radius: 9px; }
  .avatar-code { font-size: 10px; }
  .account-name { max-width: 8ch; }
}
