:root {
    --bg-color: #fff5f8;
    --card-bg: #ffffff;
    --text-color: #231824;
    --text-muted-color: #725d66;
    --primary-color: #b21765;
    --primary-shadow-color: rgba(194, 34, 104, 0.3);
    --secondary-color: #fce8f1;
    --secondary-hover-color: #f7d7e6;
    --input-bg: #fffdfd;
    --input-border-color: #e8becf;
    --accent-color: #aa2268;
    --accent-glow-color: #ff4d6d;
    --border-color: #e7bfcd;
    --winner-border-color: #edc3d6;
    --danger-color: #b72546;
    --tag-bg: #fff5f9;
    --footer-bg: #ffffff;
    --claimed-bg: #dff6eb;
    --claimed-text: #08744a;
    --stage-start: #7036c9;
    --stage-middle: #a52283;
    --stage-end: #ff4d6d;
}

body.theme-candy {
    --bg-color: #fff5f8;
    --card-bg: #ffffff;
    --text-color: #231824;
    --text-muted-color: #725d66;
    --primary-color: #b21765;
    --primary-shadow-color: rgba(194, 34, 104, 0.3);
    --secondary-color: #fce8f1;
    --secondary-hover-color: #f7d7e6;
    --input-bg: #fffdfd;
    --input-border-color: #e8becf;
    --accent-color: #aa2268;
    --accent-glow-color: #ff4d6d;
    --border-color: #e7bfcd;
    --winner-border-color: #edc3d6;
    --danger-color: #b72546;
    --tag-bg: #fff5f9;
    --footer-bg: #ffffff;
    --claimed-bg: #dff6eb;
    --claimed-text: #08744a;
    --stage-start: #7036c9;
    --stage-middle: #a52283;
    --stage-end: #ff4d6d;
}

body.theme-forest {
    --bg-color: #f0f8e8; --card-bg: #fffef7; --text-color: #3e382b;
    --text-muted-color: #675b49; --primary-color: #28743a; --primary-shadow-color: rgba(40,116,58,.25);
    --secondary-color: #e8f2db; --secondary-hover-color: #d9e8c8; --input-bg: #fffef7;
    --input-border-color: #bdcfaa; --accent-color: #286c37; --accent-glow-color: #ff7f50;
    --border-color: #c9d7ba; --winner-border-color: #b7d1a7; --danger-color: #b8463c;
    --tag-bg: #f1f7e8; --footer-bg: #fffef7; --stage-start: #146747;
    --stage-middle: #418d42; --stage-end: #e6963c;
}
body.theme-sakura {
    --bg-color: #fdf2f8; --card-bg: #ffffff; --text-color: #3e2246;
    --text-muted-color: #78596e; --primary-color: #a82879; --primary-shadow-color: rgba(168,40,121,.25);
    --secondary-color: #f7e5f5; --secondary-hover-color: #f0d4ec; --input-bg: #fffaff;
    --input-border-color: #e5c4df; --accent-color: #a82879; --accent-glow-color: #ee87ad;
    --border-color: #e7cadf; --winner-border-color: #e4c4db; --danger-color: #bd3659;
    --tag-bg: #fff4fb; --footer-bg: #ffffff; --stage-start: #7130aa;
    --stage-middle: #c3358e; --stage-end: #f48cb0;
}
body.theme-midnight {
    --bg-color: #101727; --card-bg: #1d293b; --text-color: #f2f6ff;
    --text-muted-color: #b5c2d3; --primary-color: #1575ad; --primary-shadow-color: rgba(21,117,173,.3);
    --secondary-color: #2c405a; --secondary-hover-color: #38516f; --input-bg: #172438;
    --input-border-color: #526781; --accent-color: #77d8fa; --accent-glow-color: #32baf0;
    --border-color: #425973; --winner-border-color: #50739a; --danger-color: #fb7185;
    --tag-bg: #263a52; --footer-bg: #1d293b; --claimed-bg: #164636;
    --claimed-text: #a5f4cb; --stage-start: #0c3975; --stage-middle: #146a9c;
    --stage-end: #39aabd;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.app-body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Plus Jakarta Sans', 'Noto Sans TC', sans-serif;
    background-image: radial-gradient(circle at 10% 20%, rgba(255, 104, 157, .06), transparent 28%), radial-gradient(circle at 90% 0%, rgba(126, 58, 197, .06), transparent 25%);
    transition: background-color .3s ease, color .3s ease;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent-color); outline-offset: 2px; }
.app-shell { width: min(100%, 1760px); margin: 0 auto; padding: 0 20px 28px; }
.app-header {
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    min-height: 80px; margin: 0 -20px 20px; padding: 12px 24px;
    background: var(--card-bg); border-bottom: 1px solid var(--border-color);
    box-shadow: 0 3px 16px rgba(83, 39, 55, .09);
}
.brand-lockup, .header-actions { display: flex; align-items: center; gap: 14px; }
.brand-lockup { min-width: 0; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; flex: none; }
.brand-copy { min-width: 0; }
.brand-eyebrow, .section-kicker { display: block; color: var(--accent-color); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.izakaya-title { margin: 2px 0 0; color: var(--accent-color); font-size: clamp(21px, 2vw, 27px); line-height: 1.2; font-weight: 900; letter-spacing: -.03em; }
.event-badge { padding: 8px 12px; border: 1px solid #ffb800; border-radius: 999px; color: #6b4b00; background: #fff1c2; font-size: 13px; font-weight: 800; white-space: nowrap; }
.header-icon-button, .header-reset-button { min-width: 44px; min-height: 44px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); color: var(--accent-color); font-size: 22px; }
.header-icon-button:hover, .header-reset-button:hover { background: var(--secondary-color); }
.header-reset-button { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; font-size: 15px; font-weight: 800; }
.header-reset-button.hidden { display: none; }

/* Event lobby */
.app-header { position: relative; z-index: 20; min-height: 92px; margin-bottom: 0; padding: 12px 24px; }
.brand-lockup { flex: 0 1 auto; gap: 12px; }
.brand-logo-wrap { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 14px; background: linear-gradient(135deg, #f34873, #a92275); }
.brand-logo { width: 38px; height: 38px; }
.brand-logo.default-logo { filter: invert(1); }
.izakaya-title { margin: 0; white-space: nowrap; font-size: clamp(20px, 1.75vw, 29px); }
.event-title-control { position: relative; flex: none; }
.event-badge { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 5px 14px; font-size: 13px; }
.event-title-popover { position: absolute; z-index: 30; top: calc(100% + 13px); left: 0; width: min(350px, calc(100vw - 32px)); padding: 18px; border: 1px solid var(--border-color); border-radius: 16px; background: var(--card-bg); box-shadow: 0 20px 50px rgba(45, 16, 36, .2); color: var(--text-color); }
.event-title-popover.hidden { display: none; }
.popover-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; color: var(--accent-color); }
.popover-heading button { width: 32px; height: 32px; border-radius: 8px; background: var(--secondary-color); }
.main-nav { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 3px 8px; min-width: 0; }
.nav-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 46px; min-height: 46px; padding: 7px; border: 0; border-bottom: 3px solid transparent; border-radius: 10px 10px 0 0; background: transparent; color: var(--text-muted-color); font-size: 15px; font-weight: 800; white-space: nowrap; }
.nav-button:hover, .nav-button.active { color: #f04368; background: var(--tag-bg); }
.nav-button.active { border-bottom-color: #ff476c; }
.nav-button > span:first-child { font-size: 21px; line-height: 1; }
.nav-button-accent { margin-left: 5px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--secondary-color); color: var(--accent-color); }
.nav-button-accent.active { border-bottom: 3px solid #ff476c; }
.header-reset-button { position: relative; display: grid; place-items: center; width: 46px; min-height: 46px; border-radius: 10px; font-size: 23px; }
.theme-control { position: relative; }
.theme-popover { position: absolute; z-index: 35; top: calc(100% + 10px); left: 0; width: 238px; padding: 15px; border: 1px solid var(--border-color); border-radius: 13px; background: var(--card-bg); box-shadow: 0 16px 35px rgba(62, 21, 43, .2); color: var(--text-color); }
.theme-popover strong { display: block; margin-bottom: 12px; font-size: 14px; }
.theme-selector { display: flex; flex-wrap: wrap; gap: 9px; }
.main-nav [data-tooltip]::after { position: absolute; z-index: 45; top: calc(100% + 8px); left: 50%; padding: 5px 9px; border-radius: 7px; background: #33242e; color: #fff; content: attr(data-tooltip); font-size: 12px; font-weight: 700; white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(-50%); visibility: hidden; }
.main-nav [data-tooltip]:hover::after, .main-nav [data-tooltip]:focus-visible::after { opacity: 1; visibility: visible; }
.main-nav > :last-child::after { left: auto; right: 0; transform: none; }
.home-section { min-height: calc(100vh - 150px); padding: 28px clamp(12px, 4vw, 76px) 34px; background-color: #fff8fa; background-image: radial-gradient(#f9a2bd 1px, transparent 1px), radial-gradient(#ffd177 1px, transparent 1px); background-size: 53px 53px; background-position: 0 0, 26px 26px; }
.home-section.hidden { display: none; }
.home-hero { max-width: 1500px; margin: 0 auto; overflow: hidden; border: 1px solid #f5d8e7; border-radius: 22px; background: #fff; box-shadow: 0 12px 38px rgba(164, 33, 100, .11); }
.home-hero-toolbar { display: flex; align-items: center; min-height: 58px; padding: 10px 24px; background: rgba(255, 245, 251, .94); }
.home-status { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; font-size: 15px; }
.home-status strong { color: var(--accent-color); }
.status-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #d9f3e7; color: #0baf70; font-weight: 900; }
.hero-visual { position: relative; display: grid; place-items: center; min-height: min(625px, 65vh); background-image: url('hero-izakaya.jpg'); background-position: center top; background-size: cover; color: #241a25; text-align: center; }
.hero-visual::before { position: absolute; inset: 0; content: ''; background: linear-gradient(180deg, rgba(255, 244, 248, .72), rgba(255, 248, 251, .66) 62%, rgba(255, 255, 255, .94)); }
.hero-visual-content { position: relative; z-index: 1; width: min(100%, 1050px); padding: 38px 25px 32px; }
.hero-kicker { display: inline-block; max-width: 100%; padding: 12px 24px; border: 1px solid #f6b7c5; border-radius: 999px; background: rgba(255, 225, 231, .8); color: #bd346c; font-size: 15px; font-weight: 800; }
.hero-visual h2 { margin: 26px auto 12px; font-size: clamp(38px, 5vw, 72px); line-height: 1.12; letter-spacing: -.055em; font-weight: 900; }
.hero-visual-content > p { margin: 0 auto; max-width: 820px; font-size: clamp(15px, 1.35vw, 21px); font-weight: 600; }
.enter-stage-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 72px; margin: 38px 0 20px; padding: 10px 40px; border-radius: 999px; font-size: 22px; font-weight: 900; }
.enter-stage-button span { padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 12px; letter-spacing: .08em; }
.home-summary { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 1500px; margin: 22px auto 0; }
.summary-card { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 82px; padding: 10px 12px; border: 1px solid #eadfe4; border-radius: 15px; background: #fff; color: #6d5b64; text-align: left; font-size: 13px; font-weight: 700; box-shadow: 0 5px 12px rgba(103, 39, 72, .04); }
button.summary-card:hover { border-color: #d44d8c; transform: translateY(-1px); }
.summary-prize-wrap { position: relative; min-width: 0; }
.summary-prize-wrap > .summary-card { width: 100%; height: 100%; }
.summary-prize-tooltip { position: absolute; z-index: 5; bottom: calc(100% + 10px); left: 0; display: block; width: min(320px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); box-shadow: 0 12px 28px rgba(83, 39, 55, .18); color: var(--text-color); font-size: 13px; opacity: 0; visibility: hidden; transform: translateY(5px); transition: opacity .15s ease, transform .15s ease; pointer-events: none; }
.summary-prize-wrap:hover .summary-prize-tooltip, .summary-prize-wrap:focus-within .summary-prize-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
.summary-prize-tooltip > strong { margin: 0 0 7px; font-size: 13px; }
.summary-prize-tooltip .prize-tooltip-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; font-weight: 600; }
.summary-prize-tooltip .prize-tooltip-row span:first-child { min-width: 0; overflow-wrap: anywhere; }
.summary-prize-tooltip .prize-tooltip-row span:last-child { flex: none; color: var(--accent-color); font-weight: 800; }
.summary-card > span:nth-child(2) { min-width: 0; }
.summary-card strong { display: block; margin-top: 3px; color: #332530; font-size: 18px; line-height: 1.25; }
.summary-card em { color: #ca2772; font-style: normal; }
.summary-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 12px; font-size: 25px; }
.summary-icon.gold { background: #fff3cd; color: #c58300; }
.summary-icon.pink { background: #ffe1eb; color: #b52670; }
.summary-icon.purple { background: #f3e5fa; color: #9041c7; }
.summary-icon.yellow { background: #fff4d6; color: #d18c0c; }
.app-footer { gap: 8px; padding-inline: max(20px, calc((100vw - 1720px)/2)); font-size: 12px; }

/* Settings and recent winners dialogs */
body.modal-open { overflow: hidden; }
.settings-overlay { position: fixed; z-index: 40; inset: 0; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(31, 20, 32, .63); backdrop-filter: blur(5px); }
.settings-overlay.hidden { display: none; }
.settings-dialog, .winners-dialog { display: flex; flex-direction: column; width: min(100%, 1050px); max-height: min(900px, calc(100vh - 36px)); overflow: hidden; border: 1px solid #eed3e2; border-radius: 22px; background: var(--card-bg); color: var(--text-color); box-shadow: 0 28px 70px rgba(28, 14, 27, .28); }
.winners-dialog { width: min(100%, 720px); }
.settings-dialog-header { display: flex; align-items: flex-start; gap: 15px; padding: 24px 30px 17px; background: var(--tag-bg); border-bottom: 1px solid var(--border-color); }
.settings-dialog-header > div { flex: 1; min-width: 0; }
.settings-header-icon { display: grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: #fbdde9; color: var(--accent-color); font-size: 25px; }
.settings-dialog-header h2 { margin: 0 0 4px; font-size: clamp(22px, 2.3vw, 29px); font-weight: 900; }
.settings-dialog-header p { margin: 0; color: var(--text-muted-color); font-size: 14px; }
.dialog-close { flex: none; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--text-color); font-size: 22px; }
.dialog-close:hover { background: var(--secondary-color); }
.settings-category-nav { display: flex; gap: 12px; flex: none; overflow-x: auto; padding: 0 28px; background: var(--tag-bg); border-bottom: 1px solid var(--border-color); }
.settings-overlay[data-mode="list"] .settings-category-nav { display: none; }
.settings-category-nav button { flex: none; min-height: 53px; padding: 7px 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text-muted-color); font-weight: 800; white-space: nowrap; }
.settings-category-nav button.active { border-bottom-color: var(--accent-color); color: var(--accent-color); }
.settings-body.setup-layout { display: block; flex: 1; min-height: 0; overflow-y: auto; padding: 0 28px 20px; }
.settings-body > .setup-intro { display: none; }
.settings-body.setup-layout > .card { padding: 24px 0 8px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.settings-body[data-category="env"] #roster-settings-card,
.settings-body[data-category="env"] > #status-message,
.settings-body[data-category="list"] #env-settings-card,
.settings-body[data-category="prize"] #roster-settings-card { display: none; }
.settings-body[data-category="env"] #env-settings-card { display: flex; flex-direction: column; }
.settings-body[data-category="env"] #tab-content-mode { display: grid !important; }
.settings-body[data-category="env"] #tab-content-visual { display: block !important; }
.settings-body[data-category="env"] #tab-content-prize { display: none !important; }
.settings-body[data-category="prize"] .env-title-field,
.settings-body[data-category="prize"] #tab-content-mode,
.settings-body[data-category="prize"] #tab-content-visual,
.settings-body[data-category="prize"] #roll-duration-settings { display: none !important; }
.settings-body[data-category="prize"] #tab-content-prize { display: block !important; }
.env-title-field { order: 1; margin-bottom: 4px; }
.env-title-field label { display: block; margin-bottom: 7px; font-size: 16px; font-weight: 800; }
.env-title-controls { position: relative; display: flex; }
.env-title-controls input { flex: 1; min-width: 0; padding: 8px 48px 8px 12px; border-radius: 9px; }
.env-title-controls button { position: absolute; right: 6px; top: 4px; width: 36px; height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--text-muted-color); font-size: 22px; }
.env-title-controls button:hover { background: var(--secondary-color); color: var(--accent-color); }
.env-title-field small { display: block; margin-top: 7px; color: var(--text-muted-color); }
#event-title-save-status { display: block; min-height: 18px; margin-top: 3px; color: var(--claimed-text); font-size: 12px; }
.settings-dialog-footer { display: flex; justify-content: flex-end; align-items: center; flex: none; gap: 12px; padding: 16px 28px; border-top: 1px solid var(--border-color); background: var(--tag-bg); }
.settings-dialog-footer .btn-primary { min-height: 44px; padding: 8px 25px; border-radius: 10px; font-weight: 800; }
.settings-dialog-footer .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.settings-cancel-button { margin-right: auto; border: 0; background: transparent; color: var(--text-muted-color); font-weight: 700; }
.env-template-button { min-height: 44px; padding: 8px 15px; border-radius: 10px; font-weight: 800; }
.settings-overlay[data-mode="list"] .settings-cancel-button,
.settings-overlay[data-mode="list"] .env-template-button,
.settings-overlay[data-mode="prize"] .env-template-button { display: none; }
.settings-overlay[data-mode="list"] .settings-dialog-footer { justify-content: flex-end; }

.env-section-title { margin: 0; color: var(--text-color); font-size: 17px; font-weight: 800; }
.env-section-description { margin: 8px 0 12px; color: var(--text-muted-color); font-size: 13px; }
.env-section-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.env-section-chip { padding: 5px 10px; border: 1px solid #ffd464; border-radius: 7px; background: #fff6d7; color: #835900; font-size: 12px; font-weight: 800; }
.settings-body[data-category="env"] #tab-content-visual { order: 2; margin-top: 20px; }
.env-visual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.env-visual-card { display: flex; flex-direction: column; min-width: 0; padding: 15px; border: 1px solid var(--border-color); border-radius: 13px; background: var(--tag-bg); }
.env-visual-card .env-section-description { flex: 1; }
.env-upload-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; min-width: 0; padding: 12px; border: 1px solid var(--border-color); border-radius: 11px; background: var(--card-bg); }
.env-upload-button { display: inline-flex; align-items: center; justify-content: center; flex: none; min-height: 42px; padding: 7px 15px; border: 1px solid var(--border-color); border-radius: 11px; background: var(--card-bg); color: var(--accent-color); font-weight: 800; cursor: pointer; }
.env-upload-button:hover { background: var(--secondary-color); }
.env-file-name { flex: 1 1 130px; min-width: 0; max-width: 100%; padding: 7px 11px; overflow: hidden; border: 1px solid var(--border-color); border-radius: 9px; color: var(--text-muted-color); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.env-reset-button { margin-left: auto; border: 0; background: transparent; color: var(--text-muted-color); font-size: 13px; cursor: pointer; }
.env-reset-button:hover { color: var(--accent-color); }
.env-duration-section { order: 3; margin-top: 24px; }
.duration-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.duration-options label { min-width: 0; cursor: pointer; }
.duration-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.duration-card { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 74px; padding: 8px; border: 1px solid var(--border-color); border-radius: 13px; background: var(--card-bg); text-align: center; }
.duration-card strong { font-size: 18px; }
.duration-card small { color: var(--text-muted-color); font-size: 12px; }
.duration-card em { padding: 3px 6px; border-radius: 99px; background: var(--accent-color); color: #fff; font-size: 10px; font-style: normal; }
.duration-options input:checked + .duration-card { border: 2px solid var(--accent-color); background: var(--tag-bg); color: var(--accent-color); }
.duration-options input:focus-visible + .duration-card { outline: 3px solid var(--accent-color); outline-offset: 2px; }
.effect-heading { margin-top: 24px; }
.effect-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; padding: 16px; border: 1px solid var(--border-color); border-radius: 14px; background: var(--tag-bg); }
.effect-options label { min-width: 0; cursor: pointer; }
.effect-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.effect-card { display: flex; align-items: center; gap: 9px; min-height: 62px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 11px; background: var(--card-bg); font-size: 14px; font-weight: 800; white-space: nowrap; }
.effect-check { display: grid; flex: none; place-items: center; width: 22px; height: 22px; border: 2px solid #c79bb0; border-radius: 6px; }
.effect-options input:checked + .effect-card { border-color: var(--accent-color); color: var(--accent-color); }
.effect-options input:checked + .effect-card .effect-check { border-color: var(--accent-color); background: var(--accent-color); color: #fff; }
.effect-options input:checked + .effect-card .effect-check::before { content: '✓'; font-size: 15px; line-height: 1; }
.effect-options input:focus-visible + .effect-card { outline: 3px solid var(--accent-color); outline-offset: 2px; }
.effect-icon { color: #ff6178; font-size: 21px; }
.settings-body[data-category="env"] #tab-content-mode { order: 4; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-top: 24px; padding: 18px; border: 1px solid var(--border-color); border-radius: 15px; background: var(--tag-bg); }
#tab-content-mode > h3 { grid-column: 1 / -1; }
#tab-content-mode > div { gap: 12px; min-width: 0; min-height: 80px; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); }
#tab-content-mode > div > div { min-width: 0; }
#tab-content-mode > div span.text-lg { font-size: 15px; }
#tab-content-mode > div span.text-sm { font-size: 12px; }
#tab-content-mode label { flex: none; }
.winners-modal-list { flex: 1; min-height: 80px; overflow-y: auto; padding: 22px 28px; }
.winners-modal-group { margin-bottom: 20px; }
.winners-modal-group h3 { margin: 0 0 9px; color: var(--accent-color); font-size: 17px; font-weight: 800; }
.winners-modal-row { display: flex; justify-content: space-between; gap: 15px; padding: 10px 13px; border: 1px solid var(--border-color); border-radius: 9px; margin-bottom: 7px; background: var(--tag-bg); }
.winners-modal-row span { color: var(--text-muted-color); font-size: 13px; }
.winners-modal-empty { margin: 18px 0; color: var(--text-muted-color); text-align: center; }

/* Setup screen */
.setup-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.setup-layout.hidden { display: none; }
.setup-intro { grid-column: 1 / -1; padding: 28px 8px 8px; }
.setup-intro h2 { margin: 5px 0 6px; font-size: clamp(28px, 3vw, 40px); font-weight: 900; letter-spacing: -.04em; }
.setup-intro p { margin: 0; color: var(--text-muted-color); }
.setup-layout > .card { min-width: 0; margin: 0; padding: 28px; border-radius: 20px; }
.setup-layout > .card > h2 { margin-top: 0; }
.setup-layout > .mt-8 { grid-column: 1 / -1; margin: 0; }
.setup-layout > #status-message { grid-column: 1 / -1; margin: 0; height: auto; min-height: 24px; }
.card { background: var(--card-bg); border: 1px solid var(--border-color); box-shadow: 0 8px 26px rgba(107, 50, 73, .08); }
.tab-btn { color: var(--text-muted-color); border-color: transparent; }
.tab-btn.active { color: var(--accent-color); border-color: var(--accent-color); font-weight: 800; }
.form-input { min-height: 42px; background: var(--input-bg); border: 1px solid var(--input-border-color); color: var(--text-color); }
.form-input::placeholder { color: var(--text-muted-color); opacity: .7; }
textarea.form-input { min-height: 144px; }
.btn-primary, .btn-secondary { border: 1px solid transparent; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.btn-primary { background: linear-gradient(105deg, var(--primary-color), var(--accent-glow-color)); color: #fff; box-shadow: 0 6px 16px var(--primary-shadow-color); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 24px var(--primary-shadow-color); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--secondary-color); color: var(--text-color); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--secondary-hover-color); }
.toggle-switch-bg:after { background-color: #fff; }
input:checked + .toggle-switch-bg { background-color: var(--primary-color); }
.theme-button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; transition: transform .2s ease; }
.theme-button.active { border-color: var(--accent-color); transform: scale(1.12); box-shadow: 0 0 0 3px var(--secondary-color); }
.prize-row { min-width: 0; }
.prize-row .prize-name { min-width: 0; }

/* Live draw dashboard */
.lottery-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 400px); grid-template-rows: auto minmax(0, 1fr) auto; gap: 20px; }
.lottery-layout.hidden { display: none; }
.live-status-bar { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 66px; padding: 10px 18px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px; }
.live-status-copy { display: flex; align-items: center; gap: 12px; font-size: 17px; white-space: nowrap; }
.live-dot { display: inline-block; flex: none; width: 11px; height: 11px; border-radius: 50%; background: #ff4d6d; box-shadow: 0 0 0 5px rgba(255,77,109,.12); }
.live-status-stats { display: flex; align-items: center; gap: 14px; }
.live-stat { display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 14px; border-left: 1px solid var(--border-color); font-size: 13px; white-space: nowrap; }
.live-stat > span { color: var(--text-muted-color); font-weight: 700; }
.live-stat > strong { color: var(--accent-color); font-size: 19px; }
.batch-control { display: flex; align-items: center; gap: 8px; }
.batch-control.hidden { display: none; }
.batch-control input { width: 60px; height: 38px; padding: 2px 5px; border-radius: 9px; font-size: 18px; font-weight: 800; text-align: center; }
#single-draw-count.hidden { display: none; }
.stage-panel { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-width: 0; min-height: 595px; overflow: hidden; border: 2px solid #f2bfd3; border-radius: 20px; background: var(--card-bg); box-shadow: 0 16px 35px rgba(116, 41, 75, .08); }
.stage-banner { position: relative; display: grid; place-items: center; min-height: 172px; padding: 20px 24px; overflow: hidden; background: linear-gradient(105deg, var(--stage-start), var(--stage-middle) 52%, var(--stage-end)); color: #fff; text-align: center; }
.stage-banner::before, .stage-banner::after { position: absolute; content: '✦'; color: rgba(255,255,255,.22); font-size: 72px; }
.stage-banner::before { top: 35px; left: 32px; }
.stage-banner::after { top: 27px; right: 36px; transform: rotate(22deg); }
.stage-banner h3 { position: relative; z-index: 1; margin: 0 auto; max-width: 96%; font-size: clamp(46px, 5.2vw, 74px); font-weight: 900; line-height: 1.15; overflow-wrap: anywhere; }
.stage-center { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; min-height: 310px; padding: 34px 20px; background: radial-gradient(circle at 50% 65%, rgba(241,205,222,.3), transparent 54%); }
.winner-display { display: flex; align-items: center; justify-content: center; width: min(100%, 720px); min-height: 260px; padding: 32px; border: 2px solid var(--winner-border-color); border-radius: 20px; background: var(--card-bg); box-shadow: 0 24px 40px rgba(42, 25, 32, .15); color: var(--text-color); font-size: clamp(38px, 5vw, 68px); font-weight: 900; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.stage-actions { grid-column: 1; grid-row: 3; display: flex; align-items: center; justify-content: center; min-height: 78px; padding: 0 20px; }
.stage-primary { width: max-content; min-height: 64px; padding: 10px 28px; border: 3px solid rgba(255,255,255,.55); border-radius: 999px; font-size: clamp(19px, 2vw, 27px); font-weight: 900; letter-spacing: .02em; }
.winners-panel { grid-column: 2; grid-row: 2 / 4; display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid var(--border-color); border-radius: 17px; background: var(--card-bg); overflow: hidden; box-shadow: 0 5px 12px rgba(75,31,51,.05); }
.winners-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 78px; padding: 17px 20px; border-bottom: 1px solid var(--border-color); background: var(--secondary-color); }
.winners-heading h3 { margin: 3px 0 0; font-size: 21px; font-weight: 900; }
.sort-button { flex: none; padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.winners-list { flex: 1; min-height: 0; padding: 14px; overflow-y: auto; }
.empty-winners { margin: 30px 0; color: var(--text-muted-color); font-size: 14px; text-align: center; }
.winners-list > div + div { margin-top: 22px; }
.winners-list h4 { margin: 0 0 8px; color: var(--accent-color); font-size: 14px; text-align: left; }
.winners-list .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 0; }
.winner-tag { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px; min-width: 0; min-height: 58px; padding: 6px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--tag-bg); font-size: 13px; text-align: left; }
.winner-name { display: block; min-width: 0; overflow: hidden; white-space: nowrap; font-size: clamp(16px, 1.25vw, 19px); line-height: 1.2; font-weight: 800; }
.winner-batch-names { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.winner-batch-names span { padding: 5px 12px; border-radius: 10px; background: var(--secondary-color); font-size: clamp(24px, 3vw, 38px); }
.winner-tag.claimed { background: var(--claimed-bg); color: var(--claimed-text); }
.claim-stamp { flex: none; min-width: 49px; min-height: 36px; padding: 3px; border: 1px solid var(--border-color); border-radius: 7px; background: var(--card-bg); color: var(--text-muted-color); font-size: 11px; font-weight: 800; white-space: nowrap; }
.winner-tag.claimed .claim-stamp { border: 3px double var(--claimed-text); border-radius: 5px; background: transparent; color: var(--claimed-text); transform: rotate(-9deg); animation: stamp-in .2s ease-out; }
@keyframes stamp-in { from { opacity: .2; transform: scale(1.4) rotate(-9deg); } to { opacity: 1; transform: scale(1) rotate(-9deg); } }
.donate-btn { min-width: 34px; min-height: 36px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--card-bg); color: var(--accent-color); font-size: 15px; }
.donate-btn:hover { background: var(--secondary-hover-color); }
.winners-footer { padding: 17px 20px; border-top: 1px solid var(--border-color); background: var(--secondary-color); }
.winners-summary { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 800; }
.winners-summary strong { color: var(--accent-color); }
.prize-progress-list { display: grid; gap: 11px; margin-top: 15px; }
.prize-progress-item { font-size: 11px; }
.prize-progress-item > div:first-child { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.prize-progress-item span { overflow-wrap: anywhere; }
.prize-progress-item strong { flex: none; color: var(--accent-color); }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: rgba(106,45,77,.13); }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary-color), var(--accent-glow-color)); }
.export-button { width: 100%; margin-top: 17px; min-height: 42px; border-radius: 10px; font-size: 13px; font-weight: 800; }

.app-footer { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 45px; padding: 12px 20px; border-top: 1px solid var(--border-color); background: var(--footer-bg); color: var(--text-muted-color); font-size: 11px; text-align: center; }
.app-footer a { color: var(--accent-color); font-weight: 800; }
.app-toast { position: fixed; z-index: 60; right: 20px; bottom: 64px; max-width: min(440px, calc(100vw - 32px)); padding: 12px 18px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); color: var(--text-color); box-shadow: 0 12px 32px rgba(45, 16, 36, .2); font-size: 14px; font-weight: 700; opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.app-toast.visible { opacity: 1; visibility: visible; transform: translateY(0); }

@media (min-width: 1101px) {
    body.stage-view .app-shell { display: flex; flex-direction: column; height: calc(100dvh - 45px); padding-bottom: 12px; }
    body.stage-view .app-header { flex: none; }
    body.stage-view .lottery-layout { flex: 1; min-height: 0; grid-template-rows: auto minmax(0, 1fr) 78px; gap: 12px; }
    body.stage-view .stage-panel { min-height: 0; }
    body.stage-view .stage-banner { flex: none; min-height: 155px; padding: 17px 20px; }
    body.stage-view .stage-center { min-height: 0; padding: 14px 20px; }
    body.stage-view .winner-display { min-height: 0; max-height: 225px; height: 100%; padding: 20px; }
    body.stage-view .stage-actions { min-height: 78px; padding: 7px 20px; }
    body.stage-view .winners-footer { flex: none; max-height: 35%; overflow-y: auto; }
}

/* Existing dialogs and draw effects */
.duplicate-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px; border-bottom: 1px solid var(--border-color); }
.duplicate-count { padding: 0 8px; border-radius: 99px; background: var(--primary-color); color: #fff; font-size: 12px; }
.winner-reveal { animation: winner-glow 1.5s ease-in-out; }
@keyframes winner-glow { 0% { transform: scale(.88); opacity: .8; } 50% { transform: scale(1.04); opacity: 1; color: var(--accent-color); text-shadow: 0 0 20px var(--primary-shadow-color); } 100% { transform: scale(1); } }
.effect-spotlight { animation: spotlight-pulse 2s ease-in-out; }
@keyframes spotlight-pulse { 0%, 100% { box-shadow: 0 24px 40px rgba(42,25,32,.15); } 50% { box-shadow: 0 0 45px var(--accent-glow-color); color: var(--accent-color); } }
.effect-marquee { animation: marquee-effect 1.2s cubic-bezier(.25,1,.5,1); }
@keyframes marquee-effect { from { transform: translateX(20%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 1100px) {
    .app-header { flex-wrap: wrap; }
    .main-nav { width: 100%; justify-content: flex-start; }
    .home-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lottery-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
    .live-status-bar, .stage-panel, .stage-actions, .winners-panel { grid-column: 1; grid-row: auto; }
    .winners-panel { min-height: 300px; max-height: calc(100dvh - 100px); }
    .winners-list { max-height: 420px; min-height: 150px; }
    .winners-footer { flex: none; max-height: 35%; overflow-y: auto; }
    body.stage-view .app-shell { padding-bottom: 100px; }
    body.stage-view .stage-actions { position: fixed; z-index: 25; right: 0; bottom: 0; left: 0; min-height: 78px; border-top: 1px solid var(--border-color); background: var(--bg-color); box-shadow: 0 -8px 24px rgba(83, 39, 55, .13); }
}
@media (max-width: 800px) {
    .setup-layout { grid-template-columns: 1fr; }
    .setup-intro, .setup-layout > .mt-8, .setup-layout > #status-message { grid-column: 1; }
    .app-header { flex-wrap: wrap; }
    .main-nav { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: thin; }
    .main-nav > button { flex: none; }
    .home-section { padding: 18px 16px 26px; }
    .hero-visual { min-height: 540px; }
    .home-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .main-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; overflow: visible; }
    .main-nav > button, .theme-control > button { width: 100%; }
    .theme-control { min-width: 0; }
    .theme-popover { top: calc(100% + 55px); left: 50%; transform: translateX(-50%); }
    .nav-button-accent { margin-left: 0; }
    .settings-overlay { align-items: stretch; padding: 8px; }
    .settings-dialog, .winners-dialog { max-height: calc(100dvh - 16px); border-radius: 15px; }
    .winners-dialog { align-self: center; min-height: min(300px, calc(100dvh - 16px)); }
    .settings-dialog-header { padding: 17px 16px 13px; }
    .settings-header-icon { width: 38px; height: 38px; font-size: 21px; }
    .settings-dialog-header p { font-size: 12px; }
    .settings-category-nav { gap: 4px; padding: 0 12px; }
    .settings-category-nav button { min-height: 46px; padding-inline: 8px; font-size: 13px; }
    .settings-body.setup-layout { padding: 0 15px 16px; }
    .settings-body.setup-layout > .card { padding: 18px 0 4px; }
    .settings-dialog-footer { padding: 12px 15px; }
    .settings-dialog-footer { flex-wrap: wrap; }
    .settings-cancel-button { margin-right: 0; }
    .env-template-button { margin-left: auto; }
    .duration-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .effect-options { grid-template-columns: 1fr; padding: 12px; }
    .env-visual-grid { grid-template-columns: 1fr; }
    .settings-body[data-category="env"] #tab-content-mode { grid-template-columns: 1fr; padding: 12px; }
    .env-upload-row { padding: 11px; }
    .env-file-name { order: 1; flex: 1 0 100%; }
    .env-reset-button { margin-left: auto; }
    .winners-modal-list { padding: 16px; }
    .app-shell { padding: 0 12px 20px; }
    .app-header { margin: 0 -12px 14px; padding: 10px 12px; gap: 8px; }
    .brand-lockup { flex-wrap: wrap; width: 100%; gap: 7px 10px; }
    .brand-logo-wrap { width: 43px; height: 43px; }
    .brand-logo { width: 30px; height: 30px; }
    .izakaya-title { font-size: 19px; }
    .event-title-control { margin-left: 53px; }
    .event-badge { padding: 5px 11px; font-size: 12px; }
    .event-title-popover { left: -53px; }
    .nav-button, .header-reset-button { width: 42px; min-height: 42px; }
    .home-section { padding: 13px 8px 24px; }
    .home-hero-toolbar { padding: 13px; }
    .home-status { font-size: 13px; }
    .hero-visual { min-height: 550px; background-position: 45% top; }
    .hero-visual::before { background: linear-gradient(180deg, rgba(255,244,248,.82), rgba(255,248,251,.76) 60%, rgba(255,255,255,.94)); }
    .hero-visual-content { padding: 27px 15px; }
    .hero-kicker { padding: 9px 12px; font-size: 11px; }
    .hero-visual h2 { margin-top: 23px; font-size: clamp(30px, 8.5vw, 49px); }
    .hero-visual-content > p { font-size: 14px; }
    .enter-stage-button { min-height: 62px; margin: 31px 0 17px; padding: 10px 21px; font-size: 18px; }
    .home-summary { gap: 8px; margin-top: 12px; }
    .summary-card { gap: 8px; min-height: 75px; padding: 8px; font-size: 11px; }
    .summary-card strong { font-size: 14px; }
    .summary-icon { width: 36px; height: 36px; font-size: 19px; }
    .app-footer { gap: 8px; padding: 12px; text-align: center; }
    .header-icon-button, .header-reset-button { min-width: 40px; min-height: 40px; }
    .header-reset-button { padding: 0 9px; font-size: 12px; }
    .setup-layout { gap: 14px; }
    .setup-intro { padding: 17px 5px 2px; }
    .setup-intro h2 { font-size: 29px; }
    .setup-layout > .card { padding: 18px; }
    .setup-layout > .card .flex.items-center.justify-between { gap: 14px; }
    .setup-layout > .card .flex.items-center.justify-between > .flex { min-width: 0; }
    .lottery-layout { gap: 14px; }
    .live-status-bar { align-items: flex-start; flex-direction: column; gap: 10px; padding: 11px 13px; }
    .live-status-copy { font-size: 15px; }
    .live-status-stats { width: 100%; gap: 0; }
    .live-stat { flex: 1; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px; font-size: 11px; }
    .live-stat:first-child { padding-left: 0; border-left: 0; }
    .live-stat > strong { font-size: 17px; }
    .batch-control input { width: 60px; height: 38px; font-size: 18px; }
    .stage-panel { min-height: 500px; }
    .stage-banner { min-height: 148px; padding: 18px 10px; }
    .stage-banner::before, .stage-banner::after { font-size: 42px; }
    .stage-banner::before { left: 12px; }
    .stage-banner::after { right: 12px; }
    .stage-banner h3 { max-width: 96%; font-size: 48px; }
    .stage-center { min-height: 270px; padding: 18px 13px; }
    .winner-display { min-height: 220px; padding: 18px; font-size: 40px; }
    .stage-actions { padding: 13px; }
    .stage-primary { min-height: 58px; font-size: 21px; }
    .claim-stamp, .donate-btn { min-height: 42px; }
    .winners-heading h3 { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
