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

body {
  background: #12121e;
  color: #d4d4e8;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

/* ===== Header Stats Bar ===== */
#header-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: linear-gradient(135deg, #1a1a30 0%, #222240 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  min-height: 36px;
}

.header-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #8899bb;
}

.header-stat .value {
  font-weight: 600;
  color: #e8e8ff;
  min-width: 20px;
}

.header-stat.gold .value { color: #ffd700; }
.header-stat.agents .value { color: #60c0ff; }
.header-stat.tasks .value { color: #6fcf97; }

.header-spacer {
  flex: 1;
}

.header-title {
  font-size: 13px;
  font-weight: 600;
  color: #aabbdd;
  letter-spacing: 0.5px;
  margin-right: 8px;
}

.header-title span {
  color: #ffd700;
}

.header-map-link {
  font-size: 12px;
  color: #8899bb;
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  margin-right: 8px;
}

.header-map-link:hover {
  color: #ffd700;
  border-color: rgba(255, 215, 0, 0.25);
}

/* ===== Game Container ===== */
#game-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ===== Fullscreen Mode ===== */
body.fullscreen #header-bar,
body.fullscreen #bottom-bar,
body.fullscreen #left-panel,
body.fullscreen #right-panel {
  display: none !important;
}

body.fullscreen #game-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
}

body.fullscreen #game-canvas-wrapper {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1001;
  background: #000;
  overflow: hidden;
}

body.fullscreen #game-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  line-height: 0;
}

body.fullscreen #game-canvas,
body.fullscreen #game-canvas-wrapper {
  width: 100%;
  height: 100%;
}

#fullscreen-btn {
  font-size: 13px;
}

/* ===== Instance Tabs ===== */
#instance-tabs {
  display: flex;
  gap: 3px;
  padding: 4px 8px;
  background: #181828;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  flex-shrink: 0;
}

.instance-tab {
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #8899bb;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s ease;
}

.instance-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #d4d4e8;
}

.instance-tab.active {
  background: #2a6a3a;
  border-color: #3a8a4a;
  color: #fff;
}

.instance-tab.new-city {
  color: #ffd700;
  border-color: rgba(255, 215, 0, 0.2);
}

.instance-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.instance-tab-group .instance-tab {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.instance-tab-action {
  padding: 3px 6px;
  min-width: 22px;
  background: rgba(255, 255, 255, 0.04);
  color: #8899bb;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  font-family: inherit;
  transition: all 0.15s ease;
}

.instance-tab-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #d4d4e8;
}

.instance-tab-action.danger:hover {
  background: rgba(180, 50, 50, 0.35);
  border-color: rgba(220, 80, 80, 0.4);
  color: #ffb0b0;
}

.instance-tab-group .instance-tab.active + .instance-tab-action,
.instance-tab-group .instance-tab.active ~ .instance-tab-action {
  border-color: rgba(58, 138, 74, 0.5);
}

/* ===== City lobby (no active instance) ===== */
#city-lobby {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 28, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

#city-lobby.visible {
  display: flex;
  pointer-events: auto;
}

.city-lobby-card {
  max-width: 420px;
  margin: 16px;
  padding: 28px 32px;
  text-align: center;
  background: rgba(22, 22, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.city-lobby-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
  color: #e8e8f0;
}

.city-lobby-card p {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.55;
  color: #8899bb;
}

.city-lobby-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.city-lobby-btn.primary {
  background: #2a6a3a;
  color: #fff;
}

.city-lobby-btn.primary:hover {
  background: #358a48;
}

body.city-lobby-active #game-container {
  opacity: 0.92;
}

/* ===== Panels ===== */
.panel {
  background: rgba(22, 22, 38, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  transition: border-color 0.2s ease;
}

#left-panel {
  width: 180px;
  min-width: 180px;
  padding: 10px;
  border-right: 1px solid rgba(212, 160, 23, 0.15);
}

#right-panel {
  width: 220px;
  min-width: 220px;
  padding: 10px;
  border-left: 1px solid rgba(59, 130, 246, 0.15);
}

#game-canvas-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #3a7a2a;
}

#game-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

#game-canvas canvas {
  display: block;
  margin: 0;
}

/* ===== Bottom Bar ===== */
#bottom-bar {
  height: 48px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: rgba(18, 18, 30, 0.95);
}

/* ===== Buttons ===== */
.btn {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #c8c8e0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: #2a6a3a;
  border-color: #3a8a4a;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #3a8a4a;
  border-color: #4a9a5a;
}

.btn-gold {
  background: rgba(180, 150, 30, 0.2);
  border-color: rgba(212, 160, 23, 0.3);
  color: #ffd700;
}

.btn-gold:hover {
  background: rgba(180, 150, 30, 0.3);
}

/* ===== Agent List ===== */
.panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7788aa;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-title.gold {
  color: #c8a820;
  border-color: rgba(212, 160, 23, 0.15);
}

.panel-title.blue {
  color: #5b8ad6;
  border-color: rgba(59, 130, 246, 0.15);
}

.agent-item {
  padding: 7px 8px;
  margin: 3px 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.agent-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.08);
}

.agent-item .rank {
  font-weight: 600;
}

.agent-item .state {
  color: #7788aa;
  font-size: 11px;
}

.agent-item .state.working {
  color: #6fcf97;
}

.agent-item .state.idle {
  color: #8899bb;
}

/* ===== Task Items ===== */
.task-item {
  padding: 7px 8px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 5px;
  border-left: 3px solid #4a8a5a;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.task-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.task-item.open { border-left-color: #4a8a5a; }
.task-item.in-progress { border-left-color: #c87a3a; }
.task-item.completed { border-left-color: #4a7ac8; }

.task-item .task-title {
  font-weight: 500;
  color: #d4d4e8;
}

.task-item .task-meta {
  font-size: 10px;
  color: #7788aa;
  margin-top: 2px;
}

.task-item .task-status {
  font-size: 10px;
  font-weight: 500;
}

.task-item .task-status.open { color: #4a8a5a; }
.task-item .task-status.in-progress { color: #c87a3a; }
.task-item .task-status.completed { color: #4a7ac8; }

.task-item.failed { border-left-color: #a44; }

/* ===== City activity log ===== */
.city-log-panel {
  max-height: 110px;
  overflow-y: auto;
  margin-bottom: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.theater-log-panel {
  max-height: 95px;
  border-color: rgba(180, 140, 255, 0.12);
}

.theater-line .city-log-msg {
  font-style: italic;
}

.city-log-line {
  font-size: 10px;
  line-height: 1.45;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
}

.city-log-time {
  color: #556;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.city-log-msg {
  flex: 1;
  word-break: break-word;
}

.city-log-empty {
  color: #556;
  font-size: 10px;
  text-align: center;
  padding: 8px 0;
}

/* ===== Dialog Overlay ===== */
#dialog-overlay {
  display: none;
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  max-height: 70vh;
  background: #1c1c32;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 14px;
  z-index: 100;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

#dialog-overlay.active {
  display: block;
  animation: dialogIn 0.18s ease-out;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

#dialog-text {
  margin-bottom: 8px;
  font-size: 13px;
  min-height: 20px;
  line-height: 1.5;
}

.dialog-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffd700;
  margin-bottom: 8px;
}

.dialog-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #8899bb;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 10px 0 4px 0;
}

.dialog-choice {
  padding: 6px 10px;
  margin: 3px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: #d4d4e8;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: all 0.12s ease;
}

.dialog-choice:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

/* ===== Create Task Dialog ===== */
.create-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.create-option:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: #4a8a5a;
}

.workflow-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.workflow-card:hover {
  border-color: #4a8a5a;
  background: rgba(255, 255, 255, 0.07);
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  transition: all 0.2s ease;
}

.drop-zone.dragover {
  border-color: #4a8a5a;
  background: rgba(74, 138, 90, 0.08);
}

/* ===== Textarea ===== */
textarea.task-input {
  width: 100%;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #d4d4e8;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

textarea.task-input:focus {
  border-color: #4a8a5a;
  outline: none;
}

input[type="text"],
input[type="number"] {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #d4d4e8;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #4a8a5a;
  outline: none;
}

/* ===== Notifications ===== */
.notification {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: notifIn 0.15s ease-out;
  pointer-events: none;
}

@keyframes notifIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.notification.info {
  background: #1a1a3a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d4d4e8;
}

.notification.success {
  background: #1a3a2a;
  border: 1px solid #4a8a5a;
  color: #6fcf97;
}

.notification.warning {
  background: #3a2a1a;
  border: 1px solid #c87a3a;
  color: #f0c070;
}

/* ===== Model Selector ===== */
.model-item {
  font-size: 11px;
  padding: 4px 8px;
}

/* ===== Misc ===== */
.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.tag.rank-bg { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
.tag.rank-m { background: rgba(200, 200, 200, 0.15); color: #c8c8c8; }
.tag.rank-az { background: rgba(74, 144, 217, 0.15); color: #5b9ae0; }
.tag.rank-z { background: rgba(128, 128, 128, 0.15); color: #a0a0a0; }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ===== Task Editor ===== */
.create-tab-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #8899bb;
  transition: all 0.15s ease;
}

.create-tab-btn:hover {
  color: #d4d4e8;
}

.task-inline-btn {
  width: auto !important;
  display: inline-block !important;
  padding: 2px 8px !important;
  font-size: 10px !important;
}

.task-action-btn {
  width: auto;
  padding: 6px 12px;
}

/* ===== Task Chat ===== */
#task-chat-area {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 8px;
}

#task-chat-type {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1px);
  border-radius: 4px;
  color: #d4d4e8;
  padding: 4px;
  font-size: 11px;
  font-family: inherit;
}

#task-chat-input {
  flex: 1;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #d4d4e8;
  font-size: 12px;
  font-family: inherit;
}

/* ===== Task Board filter buttons */
.task-filter-btn {
  padding: 2px 6px;
  font-size: 9px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}

.task-filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Reduced opacity for archived tasks */
.task-item .archived {
  opacity: 0.5;
}

/* ===== Chat Panel (slide-up drawer) ===== */
#chat-panel {
  display: none;
  position: fixed;
  bottom: 48px;
  left: 0;
  right: 0;
  height: 320px;
  background: rgba(18, 18, 34, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 60;
  flex-direction: column;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.3);
}

#chat-panel.active {
  display: flex;
  animation: chatSlideUp 0.2s ease-out;
}

@keyframes chatSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#chat-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

#chat-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffd700;
}

#chat-target-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #d4d4e8;
  padding: 3px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  min-width: 120px;
}

#chat-target-select:hover {
  border-color: rgba(255, 215, 0, 0.3);
}

#chat-panel-close {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8899bb;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: inherit;
  transition: all 0.12s ease;
}

#chat-panel-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

#chat-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-empty {
  color: #556;
  font-size: 12px;
  text-align: center;
  padding: 40px 0;
}

.chat-msg {
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 85%;
  font-size: 12px;
  line-height: 1.5;
  animation: msgIn 0.15s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.player {
  align-self: flex-end;
  background: rgba(42, 106, 58, 0.2);
  border: 1px solid rgba(42, 106, 58, 0.25);
  border-bottom-right-radius: 2px;
}

.chat-msg.agent {
  align-self: flex-start;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-bottom-left-radius: 2px;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.chat-msg-sender {
  font-weight: 600;
  font-size: 11px;
  color: #aabbdd;
}

.chat-target-badge {
  font-size: 9px;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  padding: 0 4px;
  border-radius: 3px;
}

.chat-msg-time {
  margin-left: auto;
  font-size: 9px;
  color: #556;
}

.chat-msg-text {
  color: #d4d4e8;
  word-break: break-word;
}

#chat-panel-input-area {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

#chat-panel-input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  color: #d4d4e8;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

#chat-panel-input:focus {
  border-color: rgba(255, 215, 0, 0.3);
  outline: none;
}

#chat-panel-send {
  padding: 6px 14px;
  background: rgba(42, 106, 58, 0.3);
  border: 1px solid rgba(42, 106, 58, 0.3);
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.12s ease;
}

#chat-panel-send:hover {
  background: rgba(42, 106, 58, 0.5);
}

/* ===== Panel mobile toggle buttons (hidden on desktop) ===== */
.panel-toggle-mobile {
  display: none;
}

/* ===== Mobile Panel Overlay (slide-in) ===== */
.mobile-panel-overlay {
  display: none;
}

/* ===== Responsive: Mobile (< 768px) ===== */
@media (max-width: 767px) {
  html, body { overflow: hidden; height: 100%; }

  #header-bar {
    gap: 6px;
    padding: 4px 8px;
    min-height: 32px;
  }

  .header-title { font-size: 11px; }
  .header-title span { font-size: 11px; }
  .header-stat { font-size: 10px; }
  .header-stat .value { font-size: 11px; min-width: 14px; }

  #game-container {
    flex-direction: column;
    position: relative;
  }

  #game-canvas-wrapper {
    width: 100%;
    height: 100%;
  }

  #game-canvas,
  #game-canvas-wrapper {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  /* Panels become full-screen overlays */
  #left-panel, #right-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 75vw !important;
    min-width: 0 !important;
    max-width: 320px;
    z-index: 80;
    padding: 12px;
    background: rgba(14, 14, 28, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
  }

  #left-panel {
    left: 0;
    top: 0;
    border-right: 1px solid rgba(212, 160, 23, 0.15);
    transform: translateX(-100%);
  }

  #right-panel {
    right: 0;
    top: 0;
    border-left: 1px solid rgba(59, 130, 246, 0.15);
    transform: translateX(100%);
  }

  #left-panel.panel-open, #right-panel.panel-open {
    transform: translateX(0);
  }

  /* Overlay backdrop */
  .mobile-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 79;
  }

  .mobile-panel-overlay.active {
    display: block;
  }

  /* Show mobile toggle buttons */
  .panel-toggle-mobile {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: #8899bb;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.12s ease;
  }

  .panel-toggle-mobile:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d4d4e8;
  }

  #bottom-bar {
    height: 42px;
    padding: 4px 6px;
    gap: 2px;
    overflow-x: auto;
  }

  #bottom-bar .btn {
    font-size: 10px;
    padding: 3px 5px;
    white-space: nowrap;
  }

  #bottom-bar input {
    max-width: 100px;
    font-size: 10px !important;
    padding: 3px 6px !important;
  }

  #chat-panel {
    height: 50vh;
    bottom: 42px;
  }

  #chat-panel-messages {
    padding: 6px 8px;
  }

  .chat-msg {
    max-width: 92%;
    font-size: 11px;
  }

  #chat-panel-input-area {
    padding: 6px 8px;
  }

  #chat-panel-input {
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Dialog overlay full-width on mobile */
  #dialog-overlay {
    width: 94vw !important;
    max-height: 60vh;
    bottom: 48px;
    font-size: 12px;
  }

  .dialog-choice {
    font-size: 11px;
    padding: 5px 8px;
  }

  .notification {
    font-size: 10px;
    padding: 6px 10px;
    max-width: 90vw;
  }

  /* Ensure canvas area fills remaining space */
  #game-canvas-wrapper {
    flex: 1;
    min-height: 0;
  }
}

/* ===== Auth ===== */
#auth-header-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-badge {
  font-size: 11px;
  color: #a8b8d8;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
}

.auth-badge.local {
  color: #6fcf97;
}

.auth-btn-in,
.auth-btn-out {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #d4d4e8;
  cursor: pointer;
}

.auth-btn-in:hover,
.auth-btn-out:hover {
  background: rgba(255, 255, 255, 0.12);
}

.auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(8, 10, 20, 0.82);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-modal.active {
  display: flex;
}

.auth-modal-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(145deg, #1e1e36, #252545);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.auth-modal-card h2 {
  font-size: 18px;
  margin-bottom: 6px;
  color: #e8e8ff;
}

.auth-sub {
  font-size: 12px;
  color: #8899bb;
  margin-bottom: 16px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #8899bb;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.active {
  background: rgba(74, 138, 90, 0.25);
  border-color: #4a8a5a;
  color: #e8ffe8;
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
}

.auth-panel label {
  display: block;
  font-size: 11px;
  color: #8899bb;
  margin-bottom: 10px;
}

.auth-panel input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #e8e8ff;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #2a6a3a;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit:hover {
  background: #358a48;
}

.auth-error {
  min-height: 18px;
  font-size: 11px;
  color: #e88;
  margin-bottom: 8px;
}

.dialog-choice.danger {
  border-color: rgba(180, 60, 60, 0.5);
  color: #eaa;
}

.dialog-choice.danger:hover {
  background: rgba(120, 40, 40, 0.25);
}

.task-output-box,
.task-description-box {
  background: #1a1a2e;
  padding: 8px;
  border-radius: 4px;
  font-size: 11px;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  border: 1px solid #333;
  line-height: 1.5;
  color: #c8c8e0;
}

.task-description-box {
  max-height: 140px;
  margin-bottom: 8px;
  font-size: 12px;
}
