:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f5f7fb;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f5f7fb; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px max(20px, env(safe-area-inset-left));
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid #e5e7eb;
  backdrop-filter: blur(12px);
}
.brand { font-size: 18px; font-weight: 800; }
.subtitle { color: #6b7280; font-size: 12px; margin-top: 2px; }
.shell { width: min(980px, 100%); margin: 0 auto; padding: 26px 18px 60px; }
.center-card {
  width: min(460px, 100%); margin: 9vh auto 0;
  padding: 34px 28px; background: white; border-radius: 24px;
  text-align: center; box-shadow: 0 12px 40px rgba(17,24,39,.08);
}
.center-card h1, .center-card h2 { margin: 10px 0; }
.center-card p { color: #6b7280; line-height: 1.55; }
.hero-icon { font-size: 48px; }
.kakao-btn {
  width: 100%; border: 0; border-radius: 14px; padding: 15px 18px;
  background: #fee500; color: #191919; font-weight: 800; margin-top: 16px;
}
.primary-btn, .secondary-btn, .danger-btn, .icon-btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700;
}
.primary-btn { background: #2563eb; color: white; }
.secondary-btn { background: white; border: 1px solid #d1d5db; color: #111827; }
.danger-btn { background: #fee2e2; color: #b91c1c; }
.icon-btn { background: #f3f4f6; color: #374151; }
.full { width: 100%; margin-top: 14px; }
.stack { display: grid; gap: 14px; text-align: left; }
.stack label { display: grid; gap: 7px; font-size: 14px; font-weight: 700; }
input, select {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid #d1d5db; background: white; outline: none;
}
input:focus, select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px #dbeafe; }
.error-text { color: #b91c1c !important; white-space: pre-wrap; }
.welcome-row {
  display: flex; justify-content: space-between; align-items: end; gap: 14px;
  margin-bottom: 20px;
}
.welcome-row h1 { margin: 0 0 5px; font-size: 28px; }
.welcome-row p { margin: 0; color: #6b7280; }
.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.stat-card {
  border: 0; background: white; border-radius: 18px; padding: 20px;
  text-align: left; display: grid; gap: 8px; color: #111827;
  box-shadow: 0 5px 18px rgba(17,24,39,.04);
}
.clickable:hover { transform: translateY(-1px); }
.stat-label { color: #6b7280; font-size: 13px; }
.stat-card strong { font-size: 23px; }
.stat-card span:last-child { color: #2563eb; font-size: 13px; }
.action-card, .panel {
  margin-top: 16px; background: white; border-radius: 18px; padding: 22px;
}
.action-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; }
.action-card h2, .panel h2 { margin: 0 0 6px; }
.action-card p { margin: 0; color: #6b7280; }
.run-progress { grid-column: 1/-1; display: flex; gap: 10px; align-items: center; color: #6b7280; }
.panel-title { display: flex; justify-content: space-between; align-items: center; }
.link-btn, .close-btn {
  background: transparent; border: 0; color: #2563eb; font-weight: 700; padding: 8px;
}
.list { display: grid; gap: 10px; margin-top: 14px; }
.list-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 14px; border: 1px solid #e5e7eb; border-radius: 14px;
}
.item-main { min-width: 0; }
.item-title { font-weight: 750; overflow-wrap: anywhere; }
.item-sub { color: #6b7280; font-size: 13px; margin-top: 4px; }
.item-actions { display: flex; gap: 7px; flex-shrink: 0; }
.mini-btn { border: 0; border-radius: 9px; padding: 8px 10px; background: #f3f4f6; }
.mini-btn.danger { color: #b91c1c; background: #fee2e2; }
dialog {
  width: min(720px, calc(100% - 24px)); max-height: 86vh; overflow: auto;
  border: 0; border-radius: 20px; padding: 22px; box-shadow: 0 24px 80px rgba(0,0,0,.22);
}
dialog::backdrop { background: rgba(17,24,39,.42); backdrop-filter: blur(2px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.dialog-head h2 { margin: 0; }
.dialog-head p { margin: 5px 0 0; color: #6b7280; }
.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.slot-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 18px; }
.slot-btn {
  padding: 11px 6px; border: 1px solid #d1d5db; background: white; border-radius: 10px;
}
.slot-btn.current { border-color: #16a34a; background: #dcfce7; }
.slot-btn.selected { border-color: #2563eb; background: #dbeafe; }
.slot-btn:disabled { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }
.history-list { display: grid; gap: 12px; margin-top: 16px; }
.history-group { border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px; }
.history-head { display: flex; justify-content: space-between; gap: 10px; }
.success { color: #15803d; }
.fail { color: #b91c1c; }
.check-row { display: flex !important; align-items: center; gap: 8px !important; }
.check-row input { width: auto; }
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: white; padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto; border: 4px solid #dbeafe;
  border-top-color: #2563eb; border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner.small { width: 20px; height: 20px; margin: 0; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

@media (max-width: 720px) {
  .shell { padding: 18px 14px 50px; }
  .stats-grid { grid-template-columns: 1fr; }
  .action-card { grid-template-columns: 1fr; }
  .action-card .primary-btn { width: 100%; }
  .welcome-row { align-items: start; }
  .welcome-row h1 { font-size: 24px; }
  .slot-grid { grid-template-columns: repeat(3,1fr); }
  .list-item { align-items: flex-start; }
}

.top-actions { display: flex; gap: 8px; align-items: center; }
.login-note {
  margin: 16px 0 0 !important;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f3f4f6;
  color: #6b7280 !important;
  font-size: 13px;
  line-height: 1.5;
}
.admin-create {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 10px;
  align-items: end;
  margin-top: 20px;
}
.admin-create label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.new-invite-box {
  margin-top: 18px;
  padding: 18px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  display: grid;
  gap: 9px;
}
.new-invite-box strong {
  font-size: 22px;
  letter-spacing: .03em;
  overflow-wrap: anywhere;
}
.admin-list-title { margin-top: 22px; }
.invite-usage {
  font-weight: 800;
  white-space: nowrap;
}
.invite-disabled { opacity: .55; }

@media (max-width: 720px) {
  .top-actions { gap: 4px; }
  #adminBtn { font-size: 12px; padding: 10px; }
  .admin-create { grid-template-columns: 1fr; }
}

.run-button-area {
  display: grid;
  justify-items: stretch;
  gap: 7px;
  min-width: 180px;
}
.run-guard-text {
  min-height: 18px;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
}
.run-guard-text.warn { color: #b45309; }
.run-guard-text.busy { color: #b91c1c; }
.primary-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .run-button-area {
    width: 100%;
    min-width: 0;
  }
}

.admin-section { margin-top: 20px; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 12px;
}
.admin-stat {
  padding: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: grid;
  gap: 5px;
}
.admin-stat span {
  color: #6b7280;
  font-size: 12px;
}
.admin-stat strong {
  font-size: 18px;
}
.user-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
}
.user-badge.admin {
  background: #fef3c7;
  color: #92400e;
}
.user-badge.pending {
  background: #fee2e2;
  color: #b91c1c;
}
.admin-user-meta {
  margin-top: 5px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.danger-outline {
  color: #b91c1c;
  background: #fff;
  border: 1px solid #fecaca;
}
.access-blocked {
  opacity: .62;
}
.user-badge.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

.automation-settings {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f9fafb;
}
.automation-settings-title { font-weight: 800; }
.automation-settings small { color: #6b7280; line-height: 1.45; }
.consent-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
}
.consent-box p { margin: 0; color: #374151; font-size: 13px; font-weight: 700; }
.consent-row { align-items: flex-start; font-size: 12px !important; font-weight: 600 !important; line-height: 1.5; }
.automation-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.automation-badge {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 800;
}
.automation-badge.on { background: #dcfce7; color: #166534; }
.automation-badge.off { background: #f3f4f6; color: #6b7280; }
.game-guard-text {
  min-height: 20px; margin-top: 12px; padding: 9px 11px;
  border-radius: 10px; background: #f9fafb; color: #6b7280; font-size: 12px;
}
.game-guard-text.warn { background: #fffbeb; color: #b45309; }
.game-guard-text.busy { background: #fef2f2; color: #b91c1c; }
.game-today-status { margin-top: 7px; font-weight: 700; }
.account-actions { flex-wrap: wrap; justify-content: flex-end; }
.game-run-account { background: #dbeafe; color: #1d4ed8; font-weight: 800; }
.game-run-account:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 720px) {
  .account-item { display: grid; }
  .account-actions { width: 100%; justify-content: flex-start; }
}


/* Phase 6.3: dashboard account actions + access expiry */
.access-expiry {
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.access-expiry.expired { color: #b91c1c; }
.access-renew-form { margin-top: 18px; }
.dashboard-account-item { align-items: flex-start; }
.dashboard-account-item .item-main { padding-top: 2px; }
.mile-run-account { background: #dcfce7; color: #166534; font-weight: 800; }
.mile-run-account:disabled { opacity: .5; cursor: not-allowed; }
.invite-state {
  color: #6b7280;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .access-expiry { width: 100%; text-align: right; font-size: 11px; }
  .dashboard-account-item { display: grid; }
  .dashboard-account-item .account-actions { width: 100%; justify-content: flex-start; }
}

.admin-game-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px;border-bottom:1px solid #e5e7eb}
.admin-game-label{display:grid;gap:4px;min-width:0;overflow-wrap:anywhere}
.admin-game-label strong{font-size:14px}
.admin-game-label small{font-size:12px;color:#6b7280}
.admin-game-row button{flex-shrink:0}
.slot-btn:disabled{opacity:.42;cursor:not-allowed;background:#f3f4f6}

/* Isolated admin workflows (game replays / people / invitations). */
#adminDialog { width:min(900px, 94vw); max-height:88dvh; overflow-y:auto; }
#adminDialog [hidden] { display:none !important; }
.admin-panel-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin:10px 0 18px; position:sticky; top:0; z-index:5; padding:8px 0; background:var(--card-bg,#fff); }
.admin-panel-tab { padding:12px 6px; border:1px solid #dbe1e9; background:#f8fafc; border-radius:12px; cursor:pointer; font-weight:700; font-size:14px; color:#526074; }
.admin-panel-tab.is-selected { background:#e7efff; border-color:#2e68ee; color:#1c4fc4; }
.admin-tab-content { min-height:100px; }
.admin-games-list { max-height:53dvh; overflow:auto; overscroll-behavior:contain; border:1px solid #eef0f4; border-radius:12px; padding:0 12px; }
.admin-games-list .admin-game-row { min-height:72px; }
@media(max-width:550px) { #adminDialog {width:96vw;} .admin-panel-tab {font-size:12px; padding:10px 3px;} .admin-games-list {max-height:55dvh;} }
