:root,
[data-theme="light"] {
  --bg:          #f2f2f7;
  --surface:     #ffffff;
  --surface2:    #e8e8f0;
  --primary:     #e94560;
  --primary-dark:#c23152;
  --accent:      #d4820f;
  --green:       #1a8c45;
  --blue:        #2a7ab5;
  --text:        #1a1a2a;
  --text-muted:  #666;
  --border:      #d8d8e4;
  --radius:      8px;
  --shadow:      0 4px 20px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg:          #111115;
  --surface:     #1c1c24;
  --surface2:    #16161e;
  --primary:     #e94560;
  --primary-dark:#c23152;
  --accent:      #f5a623;
  --green:       #2ecc71;
  --blue:        #5b9ecf;
  --text:        #e0e0e0;
  --text-muted:  #888;
  --border:      #28283a;
  --radius:      8px;
  --shadow:      0 4px 20px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .2s, color .2s;
}

.theme-toggle-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.theme-toggle-btn:hover { border-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(.9); }
.btn-sm       { padding: 5px 12px; font-size: 13px; }
.btn-full     { width: 100%; }
.btn-drink    { background: #e74c3c; color: #fff; }
.btn-drink:hover { background: #c0392b; }
.btn-bk       { background: #8e44ad; color: #fff; }
.btn-bk:hover { background: #7d3c98; }
.btn-safe     { background: #5dade2; color: #fff; }
.btn-safe:hover { background: #3498db; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0; width: 500px; max-width: 95vw;
  box-shadow: var(--shadow);
}
.modal-sm { width: 320px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--primary); }
.modal-body  { padding: 20px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px;
}
.form-group input {
  width: 100%; padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px; outline: none;
  -webkit-text-fill-color: var(--text);
}
.form-group input:focus { border-color: var(--primary); }
.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg) inset;
  transition: background-color 9999s ease-in-out 0s;
}
.optional { font-size: 11px; color: var(--text-muted); }

.alert {
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 12px; font-size: 13px;
}
.alert-error { background: rgba(233,69,96,.12); border: 1px solid var(--primary); color: var(--primary); }

.loading { color: var(--text-muted); font-size: 13px; padding: 20px; text-align: center; }

.theme-toggle-wrap { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.menu-empty-hint   { color: var(--text-muted); font-size: 12px; padding: 8px; }
.input-readonly    { opacity: .7; cursor: default; }
.start-event-readonly { margin-top: 8px; }

.toast-msg {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; z-index: 9999; pointer-events: none;
  white-space: nowrap;
}

.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover { color: var(--primary); }

.lobby-body { display: flex; flex-direction: column; min-height: 100vh; }

.lobby-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(24px, calc((100% - 1000px) / 2 + 24px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.logo-area { display: flex; align-items: baseline; gap: 10px; }
.logo-text  { font-size: 22px; font-weight: 800; color: var(--primary); }
.logo-sub   { font-size: 12px; color: var(--text-muted); }
.user-area  { display: flex; align-items: center; gap: 10px; }
.username   { font-size: 14px; font-weight: 600; }
.user-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600;
}
.user-badge.member { background: rgba(26,140,69,.15); color: var(--green); }
.user-badge.guest  { background: rgba(212,130,15,.15); color: var(--accent); }

.lobby-main { flex: 1; padding: 24px; max-width: 1000px; margin: 0 auto; width: 100%; }
.lobby-top  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 18px; font-weight: 700; }

.room-list  { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

.room-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.room-card:hover {
  border-color: var(--primary); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(233,69,96,.12);
}
.room-card-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.room-card-meta  { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; }
.room-card-status {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 20px; margin-bottom: 8px; font-weight: 600;
}
.status-waiting { background: rgba(42,122,181,.15); color: var(--blue); }
.status-setup   { background: rgba(212,130,15,.15);  color: var(--accent); }
.status-playing { background: rgba(233,69,96,.15);   color: var(--primary); }
.lock-icon { font-size: 12px; color: var(--accent); }

.player-count-select { display: flex; gap: 6px; flex-wrap: wrap; }
.count-btn {
  padding: 6px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); cursor: pointer; font-size: 13px;
  transition: all .1s;
}
.count-btn.active  { background: var(--primary); border-color: var(--primary); color: #fff; }
.count-btn:hover:not(.active) { border-color: var(--primary); }

.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-container {
  width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 28px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center; font-size: 28px; font-weight: 800;
  color: var(--primary); margin-bottom: 20px;
}
.auth-tabs {
  display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 10px; background: none; border: none;
  color: var(--text-muted); font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.auth-tab.active   { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form         { display: none; }
.auth-form.active  { display: block; }
.auth-note { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.auth-back { text-align: center; margin-top: 16px; }
.auth-back a { color: var(--text-muted); font-size: 13px; text-decoration: none; }
.auth-back a:hover { color: var(--primary); }

.waiting-body {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; padding: 20px; background: var(--bg);
}
.waiting-container {
  display: flex; gap: 20px; width: 100%; max-width: 960px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; min-height: 540px;
  box-shadow: var(--shadow);
}
.waiting-left {
  width: 280px; flex-shrink: 0; padding: 20px;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.room-info { margin-bottom: 16px; }
.room-info h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.room-capacity { font-size: 13px; color: var(--accent); font-weight: 600; }

.player-list { flex: 1; margin-bottom: 16px; }
.player-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 6px;
  background: var(--bg);
}
.player-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.player-name { font-size: 14px; font-weight: 600; }
.player-host { font-size: 11px; color: var(--accent); }
.player-disconnected { opacity: .4; }

.waiting-actions { display: flex; gap: 8px; align-items: center; }
.waiting-msg { font-size: 12px; color: var(--text-muted); }

.waiting-right { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.waiting-right h3 { font-size: 16px; font-weight: 700; }
.slot-count { font-size: 13px; color: var(--text-muted); font-weight: 400; }

.preset-menus { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.preset-label { font-size: 12px; color: var(--text-muted); }
.custom-menu-input { display: flex; gap: 8px; }
.custom-menu-input input {
  flex: 1; padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; outline: none;
}
.custom-menu-input input:focus { border-color: var(--primary); }

.menu-list {
  flex: 1; overflow-y: auto; max-height: 260px;
  background: var(--bg); border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--surface);
  border-radius: 6px; font-size: 13px; border: 1px solid var(--border);
}
.menu-item-text { flex: 1; }
.menu-item-tag {
  font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-right: 6px;
}
.tag-drink { background: rgba(231,76,60,.15); color: #e74c3c; }
.tag-bk    { background: rgba(142,68,173,.15); color: #9b59b6; }
.tag-custom{ background: rgba(42,122,181,.15); color: var(--blue); }
.menu-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.menu-remove:hover { color: var(--primary); }

.btn-kick {
  margin-left: auto; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; cursor: pointer;
  background: rgba(233,69,96,.12); border: 1px solid rgba(233,69,96,.3);
  color: var(--primary); transition: background .15s;
}
.btn-kick:hover { background: var(--primary); color: #fff; }

.board-actions { display: flex; gap: 8px; }
.start-event-config { display: flex; align-items: center; gap: 8px; }
.start-event-config label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.start-event-config input {
  flex: 1; padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; outline: none;
}
.readonly-note { font-size: 13px; color: var(--text-muted); }
