:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(18, 27, 49, .9);
  --panel-2: rgba(25, 38, 67, .9);
  --line: rgba(148, 163, 184, .2);
  --muted: #9aa8c2;
  --text: #f5f7fb;
  --cyan: #38bdf8;
  --purple: #a78bfa;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #1e2a50 0, transparent 42%), var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding: 28px; }
.home, .room-layout { max-width: 1320px; margin: 0 auto; }
.home { min-height: calc(100vh - 56px); display: grid; align-content: center; gap: 30px; }
.brand { display: flex; justify-content: space-between; gap: 18px; align-items: end; }
.brand h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4.8rem); letter-spacing: .04em; }
.brand p { max-width: 500px; margin: 0; color: var(--muted); }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mode-card, .panel, .room-side, .game-frame, .chat-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 22px 70px rgba(0, 0, 0, .25); }
.mode-card { min-height: 205px; padding: 25px; text-align: left; transition: transform .2s ease, border-color .2s ease; }
.mode-card:hover { transform: translateY(-4px); border-color: rgba(56, 189, 248, .65); }
.mode-card strong { display: block; font-size: 1.2rem; letter-spacing: .14em; }
.mode-card span { display: block; margin-top: 14px; color: var(--muted); }
.mode-card.judge { border-top: 3px solid var(--purple); }
.mode-card.host { border-top: 3px solid var(--cyan); }
.mode-card.guest { border-top: 3px solid var(--green); }
.mode-card.note { border-top: 3px solid var(--orange); }
.mode-card.diy { border-top: 3px solid #e879f9; }
.mode-card.watch { border-top: 3px solid #f472b6; }
.mode-card.profile { border-top: 3px solid #facc15; }
.panel { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label, .label { color: var(--muted); font-size: .85rem; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: rgba(5, 10, 25, .65); color: var(--text); border-radius: 10px; padding: 11px 12px; }
textarea { resize: vertical; min-height: 180px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(56, 189, 248, .35); border-color: var(--cyan); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.room-invite-row { align-items: center; }
.room-invite-url { flex: 1 1 280px; min-width: 0; font-size: .82rem; }
.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; color: var(--text); background: #243354; }
.btn:hover { filter: brightness(1.14); }
.btn.primary { background: linear-gradient(135deg, #0284c7, #4f46e5); }
.btn.success { background: linear-gradient(135deg, #047857, #0f766e); }
.btn.warn { background: linear-gradient(135deg, #c2410c, #9a3412); }
.btn.danger { background: #7f1d1d; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.muted { color: var(--muted); }
.room-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); gap: 16px; min-height: calc(100vh - 56px); }
.host-layout {
  grid-template-columns: minmax(360px, 1fr) minmax(0, 1fr);
  height: calc(100dvh - 56px);
  min-height: 0;
  align-items: stretch;
}
.room-side { padding: 18px; display: grid; align-content: start; gap: 14px; overflow: auto; }
.active-room-workspace { display: grid; gap: 14px; }
.sidebar-group { border-top: 1px solid var(--line); }
.sidebar-group > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; padding: 10px 2px 8px; color: #dbeafe; font-weight: 750; cursor: pointer; list-style: none; }
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary::before { content: '›'; color: var(--cyan); font-size: 1.3rem; line-height: 1; transition: transform .16s ease; }
.sidebar-group[open] > summary::before { transform: rotate(90deg); }
.sidebar-group > summary > span { flex: 1; }
.sidebar-group > summary > strong { color: var(--muted); font-size: .74rem; font-weight: 600; text-align: right; }
.sidebar-group-content { display: grid; gap: 14px; padding: 0 0 8px; }
.sidebar-group-content > .section:first-child { border-top: 0; padding-top: 4px; }
.game-frame { position: relative; min-height: 600px; overflow: hidden; }
.game-frame iframe { width: 100%; height: calc(100vh - 56px); min-height: 600px; border: 0; background: #0a0a1a; }
.connection-blocker { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(2, 6, 23, .82); backdrop-filter: blur(5px); }
.connection-blocker[hidden] { display: none; }
.connection-blocker > div { display: grid; gap: 8px; width: min(420px, 100%); padding: 20px; border: 1px solid rgba(34, 211, 238, .55); border-radius: 8px; background: rgba(15, 23, 42, .96); text-align: center; box-shadow: 0 18px 55px rgba(0, 0, 0, .45); }
.connection-blocker strong { color: #cffafe; font-size: 1.05rem; }
.connection-blocker span { color: var(--muted); font-size: .85rem; line-height: 1.6; }
.host-layout .room-side {
  height: 100%;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.host-layout .game-frame {
  height: 100%;
  min-height: 0;
}
.host-layout .game-frame iframe {
  display: block;
  height: 100%;
  min-height: 0;
}
.room-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.room-head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.room-code { color: var(--cyan); font: 700 1.45rem/1.1 ui-monospace, monospace; letter-spacing: .12em; }
.section { padding-top: 14px; border-top: 1px solid var(--line); }
.section h2, .section h3 { margin: 0 0 10px; font-size: 1rem; }
.player-list { display: grid; gap: 8px; }
.player-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6, 12, 29, .5); }
.player-row.host-player-row { grid-template-columns: 30px minmax(0, 1fr) auto auto auto; }
.host-checklist .checklist-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.host-checklist .checklist-row:last-child { border-bottom: 0; }
.host-checklist .checklist-row strong { color: var(--accent); font-weight: 600; text-align: right; }
.wolf-vote-panel { border-color: rgba(248, 113, 113, .42); }
.wolf-vote-host-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 12px; border: 1px solid rgba(251, 146, 60, .45); border-radius: 8px; background: rgba(124, 45, 18, .16); }
.wolf-vote-host-status.ready { border-color: rgba(52, 211, 153, .55); background: rgba(6, 78, 59, .2); }
.wolf-vote-host-status strong { color: #fed7aa; font-size: .82rem; }
.wolf-vote-host-status.ready strong { color: #a7f3d0; }
.wolf-vote-host-status .btn { flex: none; }
.player-number { color: var(--cyan); font-weight: 700; }
.player-score { color: #fcd34d; font: 700 .82rem/1 ui-monospace, monospace; white-space: nowrap; }
.ai-badge { display: inline-flex; align-items: center; margin-left: 5px; padding: 2px 6px; border: 1px solid rgba(34,211,238,.45); border-radius: 999px; color: #67e8f9; background: rgba(8,145,178,.12); font: 700 .68rem/1.2 ui-monospace, monospace; vertical-align: middle; white-space: nowrap; }
.player-admin-actions { display: flex; justify-content: flex-end; }
.player-admin-actions .btn { padding: 5px 8px; font-size: .76rem; }
.member-roster { display: grid; gap: 12px; }
.member-group { display: grid; gap: 7px; }
.member-group + .member-group { padding-top: 10px; border-top: 1px dashed var(--line); }
.member-group-title { color: #cbd5e1; font-size: .78rem; font-weight: 700; letter-spacing: .08em; }
.member-host { grid-template-columns: 54px minmax(0, 1fr) auto; border-color: rgba(56,189,248,.38); background: rgba(14,116,144,.12); }
.spectator-row { grid-template-columns: 54px minmax(0,1fr) auto auto auto; }
.spectator-permission { padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.spectator-permission.god { border-color: rgba(167,139,250,.55); color: #c4b5fd; background: rgba(109,40,217,.14); }
.mode-switch-panel { display: grid; gap: 10px; }
.mode-switch-panel .btn { justify-self: start; }
.status { font-size: .78rem; color: var(--muted); }
.status.ready, .status.confirmed { color: var(--green); }
.status.offline { color: var(--orange); }
.identity-card { min-height: 190px; display: grid; place-items: center; padding: 20px; border: 1px solid #4c5b84; border-radius: 14px; background: repeating-linear-gradient(135deg, #182546, #182546 10px, #202f56 10px, #202f56 20px); text-align: center; user-select: none; }
.identity-card.revealed { background: linear-gradient(145deg, #3b1d6b, #112d5d); border-color: var(--purple); }
.identity-card strong { display: block; font-size: 1.7rem; }
.phase-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: rgba(56, 189, 248, .13); color: var(--cyan); font-size: .8rem; }
.phase-title { margin: 9px 0 0; font-size: 1.6rem; }
.timer { margin-top: 12px; padding: 12px; border-radius: 10px; background: rgba(5, 10, 25, .7); font: 700 1.8rem/1 ui-monospace, monospace; text-align: center; }
.timer.over { color: var(--red); }
.privacy-hint { margin: 10px 0; padding: 10px 12px; border-left: 3px solid var(--orange); background: rgba(251, 146, 60, .08); color: #fed7aa; font-size: .84rem; }
.private-info { margin: 10px 0; border-color: rgba(167, 139, 250, .45); }
.private-info strong { display: block; margin-bottom: 6px; color: var(--purple); }
.private-info div { padding: 4px 0; color: #ddd6fe; font-size: .84rem; }
.announcement-button { border-color: rgba(251, 146, 60, .55); color: #fed7aa; background: rgba(154, 52, 18, .38); }
.announcement-button.active { border-color: #fb923c; background: linear-gradient(135deg, #c2410c, #9a3412); box-shadow: 0 0 0 2px rgba(251, 146, 60, .16), 0 8px 24px rgba(154, 52, 18, .28); }
.announcement-panel { margin: 0 0 4px; padding: 16px; border: 1px solid rgba(251, 146, 60, .6); border-radius: 14px; background: linear-gradient(145deg, rgba(120, 53, 15, .38), rgba(30, 20, 28, .84)); box-shadow: 0 12px 38px rgba(124, 45, 18, .2); }
.announcement-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.announcement-head h3 { margin: 8px 0 0; color: #ffedd5; }
.announcement-badge { background: rgba(251, 146, 60, .18); color: #fdba74; }
.announcement-meta { margin: 10px 0; color: #fdba74; font-size: .78rem; }
.announcement-content { max-height: 52vh; overflow: auto; padding: 12px; border: 1px solid rgba(251, 146, 60, .22); border-radius: 10px; background: rgba(10, 10, 20, .48); color: #fff7ed; line-height: 1.65; white-space: normal; }
.announcement-content strong { color: #fed7aa; }
.announcement-editor { display: grid; gap: 12px; }
.announcement-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.announcement-list { display: grid; gap: 12px; max-height: 58vh; overflow: auto; }
.announcement-item { padding: 12px; border: 1px solid rgba(251, 146, 60, .32); border-radius: 10px; background: rgba(10, 10, 20, .28); }
.announcement-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.announcement-item-head h4 { margin: 0; color: #ffedd5; }
.announcement-item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.announcement-item-actions .btn { padding: 6px 9px; font-size: .8rem; }
.announcement-form-title { padding-top: 12px; border-top: 1px solid rgba(251, 146, 60, .28); color: #fdba74; font-weight: 700; }
.score-management { margin: 12px 0; padding: 16px; border: 1px solid rgba(250, 204, 21, .5); border-radius: 14px; background: rgba(113, 63, 18, .18); }
.management-audit-list { display: grid; gap: 8px; max-height: 360px; margin-top: 12px; overflow: auto; }
.management-audit-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.management-audit-row div { min-width: 0; }
.management-audit-row strong, .management-audit-row span { display: block; overflow-wrap: anywhere; }
.management-audit-row span { margin-top: 3px; color: var(--muted); font-size: .76rem; }
.management-audit-row code { flex: none; color: #8bd5ca; font-size: .72rem; }
.score-badge { background: rgba(250, 204, 21, .16); color: #fde68a; }
.score-admin-list { display: grid; gap: 8px; margin-top: 12px; }
.score-admin-card { padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-admin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(90px, 120px) auto auto; align-items: center; gap: 7px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.score-admin-card .score-admin-row { border-bottom: 0; }
.score-admin-row strong { color: #fcd34d; white-space: nowrap; }
.score-admin-row input { padding: 7px 8px; }
.score-admin-row .btn { padding: 7px 9px; font-size: .8rem; }
.score-history { display: grid; gap: 6px; margin-top: 8px; }
.score-history-row { padding: 7px 8px; border-left: 2px solid #fcd34d; background: rgba(15, 23, 42, .45); }
.score-history-row > span, .score-history-row > strong { display: block; }
.score-status { margin: 12px 0; padding: 10px 12px; border: 1px solid rgba(250, 204, 21, .35); border-radius: 10px; color: #fde68a; background: rgba(113, 63, 18, .18); }
.join-request-list { display: grid; gap: 8px; margin-top: 10px; }
.join-request-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px; border: 1px solid rgba(56, 189, 248, .28); border-radius: 10px; background: rgba(6, 12, 29, .5); }
.join-request-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; align-items: center; }
.join-request-actions select { width: auto; min-width: 92px; padding: 7px 8px; }
.join-pending-panel { width: min(620px, 100%); margin: auto; }
.join-pending-message { padding: 12px; border-left: 3px solid var(--orange); background: rgba(251, 146, 60, .08); color: #fed7aa; }
.host-tools { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 10, 25, .52); }
.host-tools h3 { margin: 0 0 12px; }
.tool-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.vote-results { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.vote-results span { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(5, 10, 25, .55); }
.transition-scene { min-height: 150px; display: grid; place-items: center; align-content: center; gap: 5px; margin: 12px 0; border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.transition-scene.is-entering { animation: scene-in .55s ease both; }
.transition-scene strong { font-size: 2rem; }
.transition-scene span { color: var(--muted); }
.night-scene { background: linear-gradient(160deg, #080d20, #28154c); }
.day-scene { background: linear-gradient(160deg, #123047, #6d4a13); }
.result-banner { display: grid; gap: 5px; margin: 12px 0; padding: 18px; border: 1px solid rgba(52, 211, 153, .45); border-radius: 12px; background: rgba(5, 80, 65, .25); }
.result-banner strong { font-size: 1.35rem; color: var(--green); }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
details pre { max-height: 280px; overflow: auto; white-space: pre-wrap; color: var(--muted); font: .78rem/1.5 ui-monospace, monospace; }
@keyframes scene-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-panel { padding: 12px; }
.chat-log { max-height: 180px; overflow: auto; display: grid; gap: 5px; margin-bottom: 8px; }
.chat-line { color: var(--muted); font-size: .85rem; }
.chat-line b { color: var(--text); }
.chat-entry { display: flex; gap: 7px; }
.chat-entry input { min-width: 0; }
.empty { padding: 18px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 1000; max-width: min(420px, calc(100vw - 36px)); padding: 12px 15px; border: 1px solid rgba(248, 113, 113, .55); border-radius: 10px; background: #3a1721; color: #fecdd3; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.small { font-size: .82rem; }
.dialog-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(2, 6, 23, .78); backdrop-filter: blur(6px); }
.dialog-card { width: min(420px, 100%); padding: 22px; border: 1px solid rgba(56, 189, 248, .45); border-radius: 16px; background: #111a31; box-shadow: 0 24px 90px rgba(0,0,0,.55); }
.dialog-card h3 { margin: 0 0 14px; }
.dialog-card input + input { margin-top: 10px; }
.form-error { min-height: 1.3em; margin-top: 8px; color: #fca5a5; }
.note-room-overlay { position: fixed; inset: 0; z-index: 60; overflow: auto; padding: 28px; background: var(--bg); }
.profile-page { align-content: start; padding-top: 5vh; }
.profile-stats { display: grid; grid-template-columns: repeat(3, auto 1fr); gap: 8px 12px; align-items: baseline; margin: 20px 0; padding: 16px; border-radius: 12px; background: rgba(5,10,25,.55); }
.profile-stats strong { color: #facc15; font-size: 1.6rem; }
.profile-games { max-height: 42vh; overflow: auto; }
.tournament-panel { display: grid; gap: 10px; }
.tournament-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(130px, 1fr) minmax(80px, .7fr) 76px auto; gap: 7px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5,10,25,.45); }
.tournament-row input { padding: 7px 8px; }
.tournament-history-row { grid-template-columns: minmax(110px, 1fr) auto minmax(180px, auto); }
.tournament-history-row .actions { margin-top: 0; justify-content: flex-end; }
.spectator-panel .result-row .btn { padding: 5px 8px; font-size: .76rem; }
.referee-layout .game-frame { position: relative; border-color: rgba(167,139,250,.48); }
.readonly-simulator-banner { position: absolute; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); padding: 7px 12px; border: 1px solid rgba(167,139,250,.5); border-radius: 999px; background: rgba(30,27,75,.94); color: #ddd6fe; font-size: .76rem; font-weight: 700; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.replay-export-groups { display: grid; gap: 6px; justify-items: end; }
.replay-export-groups .actions { margin-top: 0; align-items: center; }
.replay-export-groups .btn { padding: 6px 9px; font-size: .76rem; }

/* NOTE workspace */
.note-shell { max-width: 1500px; min-height: calc(100vh - 56px); margin: 0 auto; }
.note-header { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 22px; }
.note-header h1 { margin: 8px 0 0; font-size: clamp(2rem, 5vw, 3.6rem); }
.note-header p { margin: 8px 0 0; }
.note-badge { background: rgba(251, 146, 60, .16); color: #fdba74; }
.note-settings { display: grid; grid-template-columns: minmax(150px, 220px) minmax(260px, 360px) 1fr; align-items: end; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.note-setting-wide { display: grid; gap: 8px; }
.note-quick-hint { align-self: center; padding-top: 18px; }
.note-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 24px; margin-top: 22px; }
.note-pane { min-width: 0; }
.note-pane-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 16px; }
.note-pane-head h2 { margin: 8px 0 0; font-size: 1.35rem; }
.note-view-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.note-add-view { display: flex; gap: 8px; align-items: center; }
.note-add-view input { width: 86px; }
.note-view-group { padding: 16px 0 22px; border-bottom: 1px solid var(--line); }
.note-view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.note-view-head h3 { margin: 0; font-size: 1.05rem; }
.note-hex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 14px 8px; }
.note-hex-item { display: grid; justify-items: center; gap: 7px; min-width: 0; }
.note-hex { width: 48px; height: 42px; padding: 0; border: 1px solid rgba(125, 211, 252, .55); color: var(--text); background: rgba(22, 45, 80, .92); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); transition: transform .15s ease, filter .15s ease; }
.note-hex:hover { transform: translateY(-3px); filter: brightness(1.25); }
.note-hex span { font: 700 1.15rem/1 ui-monospace, monospace; }
.note-identity { width: 100%; min-height: 1.35em; color: var(--muted); text-align: center; font-size: .8rem; overflow-wrap: anywhere; }
.role-wolf { background: rgba(127, 29, 29, .75); border-color: rgba(248, 113, 113, .8); }
.role-third { background: rgba(131, 24, 67, .75); border-color: rgba(244, 114, 182, .8); }
.role-good { background: rgba(12, 74, 110, .78); border-color: rgba(125, 211, 252, .75); }
.role-text-wolf { color: #fca5a5; }
.role-text-third { color: #f9a8d4; }
.role-text-good { color: #bae6fd; }
.note-speech-pane { display: grid; align-content: start; min-height: 0; }
.note-speech { min-height: 390px; resize: vertical; font: .95rem/1.7 ui-monospace, monospace; }
.note-ai { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.note-ai-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.note-ai-head h3 { margin: 0; font-size: 1.05rem; }
.note-ai-mode-label { display: flex; align-items: center; gap: 7px; width: fit-content; }
.note-info { position: relative; display: inline-grid; place-items: center; width: 19px; height: 19px; padding: 0; border: 1px solid rgba(125, 211, 252, .65); border-radius: 50%; color: #bae6fd; background: transparent; font: 700 .75rem/1 sans-serif; cursor: help; }
.note-info-tip { position: absolute; z-index: 4; left: 0; bottom: calc(100% + 9px); width: min(300px, calc(100vw - 56px)); padding: 10px 12px; border: 1px solid rgba(125, 211, 252, .38); border-radius: 8px; background: rgba(2, 6, 23, .98); color: #dbeafe; font: .76rem/1.55 system-ui, sans-serif; box-shadow: 0 12px 32px rgba(0, 0, 0, .42); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(4px); transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
.note-info:hover .note-info-tip, .note-info:focus .note-info-tip, .note-info:focus-within .note-info-tip { opacity: 1; visibility: visible; transform: translateY(0); }
.note-ai-actions { align-items: center; }
.note-ai-prompt { min-height: 90px; }
.note-ai-result { min-height: 90px; max-height: 360px; overflow: auto; margin: 14px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5, 10, 25, .65); color: #dbeafe; white-space: pre-wrap; font: .86rem/1.6 ui-monospace, monospace; }
.note-stream-toggle { display: flex; align-items: center; gap: 8px; width: fit-content; margin-top: 10px; color: var(--muted); font-size: .85rem; }
.note-stream-toggle input { width: auto; }
.note-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(2, 6, 23, .68); backdrop-filter: blur(5px); }
.note-overlay.hidden { display: none; }
.note-modal { width: min(900px, 100%); max-height: min(88vh, 820px); overflow: auto; padding: 20px; border: 1px solid rgba(148, 163, 184, .42); border-radius: 14px; background: rgba(15, 23, 42, .97); box-shadow: 0 25px 100px rgba(0, 0, 0, .5); }
.note-modal-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 12px; }
.note-modal-head h3 { margin: 8px 0 0; font-size: 1.25rem; }
.note-selected-roles { display: flex; flex-wrap: wrap; gap: 7px; min-height: 42px; margin: 10px 0 16px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.note-role-chip { border: 1px solid transparent; border-radius: 999px; padding: 6px 10px; color: var(--text); }
.note-role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.note-role-grid-quick { margin-bottom: 18px; }
.note-role-choice { display: grid; gap: 2px; min-height: 42px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: rgba(30, 41, 59, .9); text-align: left; }
.note-role-choice:hover { border-color: var(--cyan); filter: brightness(1.18); }
.note-role-choice span { color: var(--muted); font-size: .68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-choice-title { margin: 14px 0 8px; color: var(--muted); font-size: .82rem; font-weight: 500; }
.note-clear-role { margin-top: 18px; }
.note-shortcut-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.note-shortcut-choice { min-height: 44px; }

/* DIY preset designer */
.diy-shell { width: min(1520px, 100%); min-height: calc(100vh - 56px); margin: 0 auto; }
.diy-header { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 20px; }
.diy-header h1 { margin: 8px 0 0; font-size: 2.4rem; }
.diy-header .btn { flex: none; white-space: nowrap; }
.diy-badge { color: #f0abfc; background: rgba(192, 38, 211, .14); }
.diy-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 120px repeat(4, auto); align-items: end; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.diy-toolbar .btn { min-height: 44px; white-space: nowrap; }
.diy-name, .diy-count { min-width: 0; }
.diy-validation { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid var(--red); background: rgba(127, 29, 29, .15); }
.diy-validation.valid { border-left-color: var(--green); background: rgba(6, 78, 59, .16); }
.diy-validation strong { min-width: 0; overflow-wrap: anywhere; }
.diy-validation.invalid strong { color: #fecaca; }
.diy-validation.valid strong { color: #a7f3d0; }
.diy-validation span { flex: none; color: var(--muted); font: .8rem/1.2 ui-monospace, monospace; }
.diy-layout { display: grid; grid-template-columns: minmax(360px, .78fr) minmax(520px, 1.22fr); gap: 26px; margin-top: 22px; }
.diy-catalog, .diy-config { min-width: 0; }
.diy-section-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; min-height: 62px; margin-bottom: 14px; }
.diy-section-head h2 { margin: 7px 0 0; font-size: 1.3rem; }
.diy-section-head input { width: min(220px, 50%); }
.diy-section-head > strong { color: #f0abfc; font: 700 .86rem/1.2 ui-monospace, monospace; }
.diy-segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.diy-segmented button { min-height: 38px; padding: 7px 8px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: rgba(5, 10, 25, .55); }
.diy-segmented button:last-child { border-right: 0; }
.diy-segmented button[aria-pressed="true"] { color: #fae8ff; background: rgba(162, 28, 175, .42); }
.diy-role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start; gap: 8px; max-height: 650px; overflow: auto; padding-right: 4px; scrollbar-gutter: stable; }
.diy-role-group-label { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 34px; margin-top: 8px; padding: 5px 2px 7px; border-bottom: 1px solid var(--line); font-size: .78rem; font-weight: 700; }
.diy-role-group-label:first-child { margin-top: 0; }
.diy-role-group-label strong { color: var(--muted); font: 500 .7rem/1 ui-monospace, monospace; }
.diy-role { position: relative; display: grid; place-items: center; min-width: 0; min-height: 54px; padding: 8px 26px 8px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: rgba(30, 41, 59, .82); text-align: center; transition: border-color .15s ease, filter .15s ease, transform .15s ease; }
.diy-role:hover { border-color: var(--cyan); filter: brightness(1.18); transform: translateY(-1px); }
.diy-role span { max-width: 100%; overflow-wrap: anywhere; }
.diy-role strong { position: absolute; top: 5px; right: 6px; display: grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; color: #fff; background: rgba(2, 6, 23, .78); font: 700 .68rem/1 ui-monospace, monospace; }
.diy-role.role-wolf { border-color: rgba(248, 113, 113, .55); background: rgba(127, 29, 29, .56); }
.diy-role.role-third { border-color: rgba(244, 114, 182, .55); background: rgba(131, 24, 67, .55); }
.diy-role.role-good { border-color: rgba(125, 211, 252, .48); background: rgba(12, 74, 110, .55); }
.diy-selected-list { display: grid; align-content: start; gap: 7px; max-height: 430px; overflow: auto; padding-right: 4px; scrollbar-gutter: stable; }
.diy-selected-row { display: grid; grid-template-columns: 34px minmax(120px, 1fr) auto auto; align-items: center; gap: 9px; min-height: 48px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: rgba(5, 10, 25, .28); }
.diy-selected-row > strong { min-width: 0; overflow-wrap: anywhere; }
.diy-seat { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(56, 189, 248, .48); border-radius: 50%; color: #bae6fd; font: 700 .75rem/1 ui-monospace, monospace; }
.diy-team { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.diy-row-actions { display: flex; gap: 5px; }
.diy-icon-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: rgba(36, 51, 84, .9); font-size: 1rem; }
.diy-icon-btn:hover { border-color: var(--cyan); filter: brightness(1.18); }
.diy-icon-btn.danger { border-color: rgba(248, 113, 113, .35); color: #fecaca; background: rgba(127, 29, 29, .6); }
.diy-icon-btn:disabled { cursor: not-allowed; opacity: .3; }
.diy-rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.diy-winner { display: flex; flex-wrap: wrap; align-content: start; gap: 10px 16px; min-width: 0; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.diy-winner legend { padding: 0 5px; color: var(--muted); font-size: .82rem; }
.diy-winner label { display: flex; align-items: center; gap: 6px; color: var(--text); white-space: nowrap; }
.diy-winner input { width: auto; }
.diy-empty { grid-column: 1 / -1; }
.checkpoint-panel { padding-top: 2px; }
.checkpoint-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; }
.checkpoint-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid rgba(148,163,184,.18); background: rgba(15,23,42,.35); }
.checkpoint-row strong { color: #e2e8f0; }
.discarded-panel { padding-top: 2px; }
.discarded-branch { margin-top: 8px; padding: 9px 10px; border: 1px solid rgba(248,113,113,.22); background: rgba(69,10,10,.16); }
.discarded-branch summary { color: #fecaca; cursor: pointer; }
.discarded-events { display: grid; gap: 7px; margin-top: 9px; }
.discarded-events > div { display: grid; gap: 2px; padding-left: 8px; border-left: 2px solid rgba(248,113,113,.35); }
.discarded-events span { color: var(--muted); font-size: .78rem; }
.timeline-list { display: grid; gap: 7px; max-height: 420px; overflow: auto; }
.timeline-row { padding: 9px 10px; border-left: 3px solid rgba(34,211,238,.55); background: rgba(15,23,42,.38); }
.timeline-row.timeline-current { border-left-color: var(--accent); background: rgba(34,211,238,.1); }
.timeline-state { display: grid; gap: 3px; margin-top: 7px; padding: 7px 9px; border-radius: 9px; background: rgba(15,23,42,.56); color: #a5b4fc; }
.timeline-row > div:first-child { display: flex; justify-content: space-between; gap: 10px; }
.timeline-row span { color: var(--muted); font-size: .72rem; }
.timeline-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.timeline-controls select, .timeline-controls input { min-height: 38px; }
.timeline-controls input { width: 112px; }
@media (max-width: 900px) {
  .app-shell { padding: 14px; }
  .brand { display: block; }
  .brand p { margin-top: 10px; }
  .mode-grid, .room-layout, .host-layout { grid-template-columns: 1fr; }
  .host-layout { height: auto; min-height: calc(100vh - 28px); }
  .host-layout .room-side { height: auto; overflow: visible; }
  .host-layout .game-frame { height: 70vh; min-height: 520px; }
  .game-frame, .game-frame iframe { min-height: 70vh; height: 70vh; }
  .note-layout { grid-template-columns: 1fr; }
  .diy-toolbar { grid-template-columns: minmax(0, 1fr) 110px repeat(2, auto); }
  .diy-toolbar .diy-name { grid-column: span 2; }
  .diy-layout { grid-template-columns: 1fr; }
  .diy-role-grid { max-height: 420px; }
  .diy-selected-list { max-height: 520px; }
  .note-settings { grid-template-columns: 1fr 1fr; }
  .note-quick-hint { grid-column: 1 / -1; padding-top: 0; }
  .tournament-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tournament-row input { width: 100%; min-width: 0; }
  .tournament-history-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 540px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .mode-card { min-height: 150px; }
  .join-request-row { display: grid; }
  .join-request-actions { justify-content: flex-start; }
  .score-admin-row { grid-template-columns: 1fr auto; }
  .score-admin-row input { grid-column: 1 / -1; }
  .spectator-row { grid-template-columns: 54px minmax(0,1fr) auto; }
  .spectator-row .player-admin-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .wolf-vote-host-status { align-items: stretch; flex-direction: column; }
  .wolf-vote-host-status .btn { width: 100%; }
  .note-header { align-items: stretch; }
  .note-header .btn { align-self: start; }
  .note-settings { grid-template-columns: 1fr; }
  .note-add-view { width: 100%; }
  .note-view-actions { width: 100%; justify-content: flex-start; }
  .note-add-view input { flex: 1; width: auto; }
  .note-pane-head { display: block; }
  .diy-header { align-items: stretch; }
  .diy-header h1 { font-size: 1.7rem; }
  .diy-header .btn { align-self: start; }
  .diy-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diy-toolbar .diy-name { grid-column: 1 / -1; }
  .diy-toolbar .btn { width: 100%; padding-inline: 8px; white-space: normal; }
  .diy-layout { gap: 34px; }
  .diy-section-head { align-items: stretch; }
  .diy-section-head input { width: min(180px, 48%); }
  .diy-selected-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .diy-team { display: none; }
  .diy-row-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .diy-rules { grid-template-columns: 1fr; }
  .note-add-view { margin-top: 12px; }
  .tournament-row { grid-template-columns: minmax(0, 1fr); }
  .tournament-history-row .actions { grid-column: auto; }
}

.home-footer-actions { justify-content: space-between; align-items: center; width: 100%; }
.debug-home-button, .debug-room-button { display: inline-flex; align-items: center; gap: 7px; }
.debug-home-button { margin-left: auto; border-color: #ef4444; color: #fecaca; background: #2a1115; }
.debug-home-button.active, .debug-room-button.active { border-color: #94a3b8; color: #f8fafc; background: #0f172a; box-shadow: inset 3px 0 #22d3ee; }
.debug-home-button.active::after, .debug-room-button.active::after { content: '✓'; color: #67e8f9; font-size: .76rem; font-weight: 800; line-height: 1; }
.debug-overlay { z-index: 120; }
.debug-console { width: min(900px, calc(100vw - 32px)); max-height: min(860px, calc(100vh - 32px)); overflow: auto; }
.debug-help, .debug-output { max-height: 260px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #070b12; color: #cbd5e1; white-space: pre-wrap; }
.debug-output { min-height: 80px; color: #86efac; }
.diagnostic-grid { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(0, 1.3fr); margin: 18px 0; border-top: 1px solid var(--line); }
.diagnostic-grid > * { padding: 10px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.diagnostic-grid > span { color: var(--muted); }
.chat-moderation { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-moderation select { min-width: 160px; }
.transfer-panel { border-color: #f59e0b; }
@media (max-width: 620px) {
  .diagnostic-grid { grid-template-columns: 1fr; }
  .diagnostic-grid > span { padding-bottom: 2px; border-bottom: 0; }
  .diagnostic-grid > strong { padding-top: 2px; }
}
