/* ============================================================
   COMBAT COMPANION — Mobile PWA Stylesheet
   Dark Fantasy Parchment Theme · Inspired by Adventurer's Codex
   ============================================================ */

/* --------------------------------------------------------
   0. GOOGLE FONTS CDN
   -------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap');

/* --------------------------------------------------------
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   -------------------------------------------------------- */
:root {
  /* Core palette — warm parchment browns (Adventurer's Codex style) */
  --bg-deep:          #1d1a16;
  --bg-card:          rgba(43, 36, 29, 0.8);
  --border:           rgba(67, 56, 45, 0.5);
  --border-light:     rgba(87, 76, 65, 0.6);
  --gold:             #dda23c;
  --gold-bright:      #e8b94e;
  --gold-dim:         #a35c29;
  --text-primary:     #f2e9d9;
  --text-secondary:   #9a8b74;
  --red:              #a63d2f;
  --red-bright:       #d4503e;
  --green:            #4a7c3f;
  --green-bright:     #5ea350;
  --blue:             #3d6b8e;
  --blue-bright:      #4d8db0;
  --purple:           #7a4d8c;
  --purple-bright:    #9b6aad;

  /* Typography */
  --font-header:      'Cinzel', serif;
  --font-body:        'Crimson Text', serif;

  /* Spacing */
  --space-xs:         4px;
  --space-sm:         8px;
  --space-md:         12px;
  --space-lg:         16px;
  --space-xl:         24px;
  --space-2xl:        32px;

  /* Sizing */
  --header-h:         52px;
  --tabbar-h:         60px;
  --radius:           8px;
  --radius-lg:        12px;
  --radius-pill:      999px;
  --transition:        0.25s ease;

  /* Safe areas */
  --safe-top:         env(safe-area-inset-top, 0px);
  --safe-bottom:      env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}

a {
  color: var(--gold);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  outline: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(67, 56, 45, 0.4);
  border-radius: 4px;
}

/* ============================================================
   3. APP SHELL
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* --- 3.1 Header Bar --- */
.header,
#header {
  flex-shrink: 0;
  height: var(--header-h);
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  background: rgba(29, 26, 22, 0.85);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header h1 {
  font-family: var(--font-header);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(221, 162, 60, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header .world-selector {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(29, 26, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header .world-selector i {
  color: var(--gold-dim);
  font-size: 11px;
}

.header .connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 6px rgba(94, 163, 80, 0.5);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.header .connection-dot.disconnected {
  background: var(--red-bright);
  box-shadow: 0 0 6px rgba(212, 80, 62, 0.5);
}

.header .connection-dot.connecting {
  background: var(--gold);
  animation: pulse-dot 1.2s infinite alternate;
}

@keyframes pulse-dot {
  0%   { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1;   transform: scale(1.2); }
}

/* --- 3.2 Content Area --- */
.content,
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--space-lg);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-lg));
}

/* --- 3.3 Tab Bar --- */
.tab-bar,
#tabbar {
  flex-shrink: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  background: rgba(29, 26, 22, 0.92);
  border-top: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.tab-bar .tab,
#tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-header);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color var(--transition);
  position: relative;
  min-height: var(--tabbar-h);
}

.tab-bar .tab i,
#tabbar button i {
  font-size: 20px;
  transition: color var(--transition), transform var(--transition);
}

.tab-bar .tab.active,
#tabbar button.active {
  color: var(--gold);
}

.tab-bar .tab.active i,
#tabbar button.active i {
  color: var(--gold-bright);
  transform: scale(1.15);
  filter: drop-shadow(0 0 6px rgba(221, 162, 60, 0.4));
}

.tab-bar .tab.active::after,
#tabbar button.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

/* --- 3.4 Tab Panels --- */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   3. AUTH SCREEN
   ============================================================ */

#auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: var(--bg-deep);
  z-index: 1000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: manipulation;
}

#auth-screen::before,
#auth-screen::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

#auth-screen::before {
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(221, 162, 60, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 100%, rgba(163, 92, 41, 0.06) 0%, transparent 50%);
}

#auth-screen::after {
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(43, 36, 29, 0.4), transparent);
}

.auth-wrapper,
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0 var(--space-xl);
  padding-top: max(var(--space-2xl), env(safe-area-inset-top));
  padding-bottom: max(var(--space-2xl), env(safe-area-inset-bottom));
  box-shadow: none;
  margin-bottom: 0;
}

/* Explicit mobile override: kill ALL card styling below 768px */
@media (max-width: 767px) {
  .auth-wrapper,
  .auth-card {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    max-width: 100% !important;
    padding-left: var(--space-xl) !important;
    padding-right: var(--space-xl) !important;
  }
  .auth-card {
    padding-top: max(var(--space-2xl), env(safe-area-inset-top)) !important;
    padding-bottom: max(var(--space-2xl), env(safe-area-inset-bottom)) !important;
  }
}

@media (min-width: 768px) {
  .auth-wrapper,
  .auth-card {
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
    padding: var(--space-2xl) var(--space-xl);
    background: linear-gradient(145deg, rgba(43, 36, 29, 0.9), rgba(35, 29, 23, 0.95));
    border: 1px solid rgba(67, 56, 45, 0.5);
    border-radius: var(--radius-lg);
    box-shadow:
      0 0 40px rgba(221, 162, 60, 0.04),
      0 8px 32px rgba(0,0,0,0.5),
      inset 0 1px 0 rgba(255,255,255,0.02);
    margin-top: auto;
    margin-bottom: auto;
  }
}

@media (min-width: 1024px) {
  /* Auth card: wider on desktop */
  .auth-wrapper,
  .auth-card {
    max-width: 480px;
  }
}

@media (min-width: 1440px) {
  .auth-wrapper,
  .auth-card {
    max-width: 520px;
  }
}

/* Auth header */
.auth-header,
.auth-logo {
  text-align: center;
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(67, 56, 45, 0.3);
}

.auth-header .logo,
.auth-logo h1 {
  font-family: var(--font-header);
  font-size: 28px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow:
    0 0 20px rgba(221, 162, 60, 0.25),
    0 2px 4px rgba(0,0,0,0.5);
}

.auth-header .logo .icon,
.auth-logo .icon,
.auth-logo i {
  display: block;
  font-size: 48px;
  margin-bottom: var(--space-sm);
  filter: drop-shadow(0 0 12px rgba(221, 162, 60, 0.35));
}

.auth-header .subtitle,
.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  letter-spacing: 1px;
  font-style: italic;
}

/* Auth step indicators */
.auth-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.auth-step-dot,
.step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(67, 56, 45, 0.6);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-header);
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-step-dot.active,
.step-dot.active {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(221, 162, 60, 0.5);
  transform: scale(1.1);
  color: var(--bg-deep);
}

.auth-step-dot.completed,
.step-dot.completed {
  background: var(--gold-dim);
  color: var(--bg-deep);
}

.auth-steps .step-line {
  width: 32px;
  height: 2px;
  background: rgba(67, 56, 45, 0.5);
  transition: background var(--transition);
}

.auth-steps .step-line.completed {
  background: var(--gold-dim);
}

/* Auth form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-step {
  display: none;
  animation: auth-fade 0.3s ease;
}

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

#auth-screen h3,
.auth-step h3 {
  font-family: var(--font-header);
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  letter-spacing: 0.5px;
}

@keyframes auth-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Form inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label,
#auth-screen label {
  font-family: var(--font-header);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.form-input,
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="number"],
.auth-card select,
#auth-screen input[type="text"],
#auth-screen input[type="email"],
#auth-screen input[type="password"],
#auth-screen input[type="number"],
#auth-screen select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(43, 36, 29, 0.7);
  border: 1px solid rgba(67, 56, 45, 0.6);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.auth-card input:focus,
.auth-card select:focus,
#auth-screen input:focus,
#auth-screen select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(221, 162, 60, 0.15), 0 0 12px rgba(221, 162, 60, 0.08);
}

.form-input::placeholder,
.auth-card input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

select.form-input,
.auth-card select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239a8b74' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Auth buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 20px;
  border-radius: 6px;
  font-family: var(--font-header);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all var(--transition);
  min-height: 48px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dim) 0%, var(--gold) 50%, var(--gold-bright) 100%);
  color: var(--bg-deep);
  border: none;
  box-shadow: 0 2px 8px rgba(221, 162, 60, 0.2);
}

.btn-primary:hover,
.btn-primary:active {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-bright) 50%, #f0cc5e 100%);
  box-shadow: 0 4px 16px rgba(221, 162, 60, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary,
.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}

.btn-secondary:hover,
.btn-secondary:active,
.btn-outline:hover,
.btn-outline:active {
  background: rgba(221, 162, 60, 0.06);
  border-color: var(--gold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 12px;
}

.btn-ghost:hover,
.btn-ghost:active {
  color: var(--gold);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
}

.btn-danger:hover,
.btn-danger:active {
  background: var(--red-bright);
}

.btn-full,
.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 36px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Auth help text */
.auth-help {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.auth-help strong {
  color: var(--gold);
}

.auth-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.auth-errors {
  color: var(--red-bright);
  font-size: 13px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  background: rgba(166, 61, 47, 0.08);
  border: 1px solid rgba(166, 61, 47, 0.3);
  margin-bottom: var(--space-md);
  display: none;
}

.auth-errors:not(:empty) {
  display: block;
}

.auth-divider {
  text-align: center;
  margin: var(--space-lg) 0;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  position: relative;
  padding: 0 var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.9), rgba(35, 29, 23, 0.95));
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
}

.auth-success {
  text-align: center;
  padding: var(--space-xl) 0;
}

.auth-success i {
  font-size: 48px;
  color: var(--green-bright);
  margin-bottom: var(--space-md);
  filter: drop-shadow(0 0 12px rgba(94, 163, 80, 0.4));
}

.auth-success h3 {
  font-family: var(--font-header);
  font-size: 20px;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.auth-success p {
  color: var(--text-secondary);
  font-size: 14px;
}

.approval-link {
  display: inline-block;
  margin-top: var(--space-sm);
  padding: 8px 16px;
  background: rgba(221, 162, 60, 0.08);
  border: 1px solid rgba(163, 92, 41, 0.4);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-header);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.api-key-entry {
  padding-top: var(--space-md);
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.api-key-entry.collapsed {
  max-height: 0;
}

.api-key-entry:not(.collapsed) {
  max-height: 200px;
}

.auth-approval-info {
  text-align: center;
  padding: var(--space-lg);
}

.auth-approval-info i {
  font-size: 24px;
  color: var(--gold);
  margin-bottom: var(--space-md);
}

.auth-approval-info p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.poll-status {
  color: var(--text-secondary);
  font-size: 12px;
  font-style: italic;
}

/* "Or enter API Key" collapsible */
.auth-api-toggle {
  text-align: center;
  margin-top: var(--space-lg);
}

.auth-api-toggle button {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  border-bottom: 1px dashed var(--text-secondary);
  padding-bottom: 1px;
  transition: color var(--transition);
}

.auth-api-toggle button:hover {
  color: var(--gold);
}

.auth-api-section {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.auth-api-section.open {
  max-height: 200px;
}

/* ============================================================
   5. CHARACTER TAB
   ============================================================ */

/* --- 5.1 Actor List --- */
.actor-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.actor-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.7), rgba(35, 29, 23, 0.8));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), transform var(--transition);
  min-height: 60px;
}

.actor-card:active {
  transform: scale(0.98);
}

.actor-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(221, 162, 60, 0.08);
}

.actor-card .portrait {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(67, 56, 45, 0.5);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-deep);
}

.actor-card .actor-info {
  flex: 1;
  min-width: 0;
}

.actor-card .actor-name {
  font-family: var(--font-header);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actor-card .actor-class {
  font-size: 12px;
  color: var(--text-secondary);
}

.actor-card .mini-hp {
  height: 4px;
  background: rgba(29, 26, 22, 0.8);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.actor-card .mini-hp .fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease, background 0.5s ease;
}

.actor-card .ac-badge {
  font-family: var(--font-header);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(221, 162, 60, 0.08);
  border: 1px solid rgba(163, 92, 41, 0.4);
  border-radius: var(--radius);
  padding: 2px 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- 5.2 Selected Actor Card --- */
.selected-actor {
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  position: relative;
}

.selected-actor .actor-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* Portrait with condition overlay container */
.portrait-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.portrait-wrap .portrait {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(67, 56, 45, 0.5);
  object-fit: cover;
  background: var(--bg-deep);
  transition: transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

.portrait-wrap .portrait-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  transition: all 0.3s ease;
}

.portrait-wrap .concentration-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
  animation: none;
  pointer-events: none;
}

.portrait-wrap.concentrating .concentration-ring {
  opacity: 1;
  animation: conc-pulse 2s ease-in-out infinite;
}

@keyframes conc-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(221, 162, 60, 0.35); border-color: var(--gold-dim); }
  50%      { box-shadow: 0 0 14px rgba(221, 162, 60, 0.65); border-color: var(--gold-bright); }
}

/* Selected actor details */
.selected-actor .actor-name {
  font-family: var(--font-header);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.selected-actor .actor-race-class {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.selected-actor .actor-level {
  font-family: var(--font-header);
  font-size: 13px;
  color: var(--gold-dim);
  margin-top: 2px;
}

.selected-actor .actor-badges {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.selected-actor .ac-badge {
  font-family: var(--font-header);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(221, 162, 60, 0.08);
  border: 1px solid rgba(163, 92, 41, 0.4);
  border-radius: var(--radius);
  padding: 2px 8px;
}

.selected-actor .speed-badge,
.selected-actor .init-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(43, 36, 29, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 8px;
}

/* --- 5.3 HP Bar --- */
.hp-bar-wrap {
  margin-bottom: var(--space-lg);
}

.hp-bar {
  height: 14px;
  background: rgba(29, 26, 22, 0.8);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.hp-bar .hp-fill {
  height: 100%;
  border-radius: calc(var(--radius) - 1px);
  transition: width 0.5s ease, background 0.5s ease;
  position: relative;
}

.hp-fill.green  { background: linear-gradient(90deg, #3a6b32, var(--green-bright)); }
.hp-fill.yellow { background: linear-gradient(90deg, #8a6d1b, #c4a626); }
.hp-fill.red     { background: linear-gradient(90deg, #6b2a22, var(--red-bright)); }

.hp-bar .temp-hp-fill {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(61, 107, 142, 0.6), var(--blue-bright));
  border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0;
  transition: width 0.5s ease;
}

.hp-bar .hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-header);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  z-index: 1;
}

/* --- 5.4 Ability Scores Grid --- */
.ability-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.ability-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-xs);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  min-height: 44px;
}

.ability-item:active {
  background: rgba(221, 162, 60, 0.04);
  border-color: var(--gold-dim);
}

.ability-item .ability-name {
  font-family: var(--font-header);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.ability-item .ability-score {
  font-family: var(--font-header);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.ability-item .ability-mod {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
}

/* --- 5.5 Condition Chips --- */
.condition-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.condition-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-family: var(--font-header);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid;
  background: rgba(0,0,0,0.2);
}

.condition-chip.concentrating  { border-color: var(--gold);    color: var(--gold); }
.condition-chip.poisoned       { border-color: var(--green);   color: var(--green-bright); }
.condition-chip.burning        { border-color: #c47a2b;        color: #d4922f; }
.condition-chip.frozen         { border-color: var(--blue);    color: var(--blue-bright); }
.condition-chip.blinded        { border-color: #6b6256;        color: #8a7d6e; }
.condition-chip.charmed        { border-color: var(--purple);  color: var(--purple-bright); }
.condition-chip.frightened     { border-color: #6b3d7a;        color: var(--purple-bright); }
.condition-chip.restrained     { border-color: #7a7058;        color: #9a8b74; }
.condition-chip.prone          { border-color: #5a5040;        color: #7a7058; }
.condition-chip.invisible      { border-color: #8a8070;       color: #b0a890; }
.condition-chip.default        { border-color: var(--border-light); color: var(--text-secondary); }

.condition-chip .chip-remove {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
  padding: 0;
  color: inherit;
}

.condition-chip .chip-remove:hover {
  opacity: 1;
}

/* ============================================================
   6. COMBAT TAB
   ============================================================ */

/* --- 6.1 Action Economy Row --- */
.action-economy {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.action-toggle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px var(--space-xs);
  border-radius: var(--radius);
  border: 2px solid var(--green);
  background: rgba(74, 124, 63, 0.08);
  color: var(--green-bright);
  font-family: var(--font-header);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  min-height: 44px;
  transition: all var(--transition);
}

.action-toggle i {
  font-size: 18px;
}

.action-toggle.spent {
  border-color: var(--red);
  background: rgba(166, 61, 47, 0.08);
  color: var(--red-bright);
  opacity: 0.7;
}

.action-toggle:active {
  transform: scale(0.95);
}

/* --- 6.2 HP Controls --- */
.hp-controls {
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.hp-display {
  text-align: center;
  margin-bottom: var(--space-md);
}

.hp-display .hp-current {
  font-family: var(--font-header);
  font-size: 48px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}

.hp-display .hp-separator {
  font-size: 24px;
  color: var(--text-secondary);
  margin: 0 4px;
}

.hp-display .hp-max {
  font-family: var(--font-header);
  font-size: 24px;
  color: var(--text-secondary);
}

.hp-display .temp-hp-line {
  font-size: 13px;
  color: var(--blue-bright);
  margin-top: 4px;
}

.hp-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  justify-content: center;
}

.hp-stepper .stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.hp-stepper .stepper-btn.heal {
  border-color: var(--green);
  color: var(--green-bright);
  background: rgba(74, 124, 63, 0.08);
}

.hp-stepper .stepper-btn.heal:active {
  background: rgba(74, 124, 63, 0.2);
}

.hp-stepper .stepper-btn.damage {
  border-color: var(--red);
  color: var(--red-bright);
  background: rgba(166, 61, 47, 0.08);
}

.hp-stepper .stepper-btn.damage:active {
  background: rgba(166, 61, 47, 0.2);
}

.hp-stepper .amount-input {
  width: 60px;
  text-align: center;
  padding: 8px;
  background: rgba(29, 26, 22, 0.5);
  border: 1px solid rgba(67, 56, 45, 0.6);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-header);
  font-size: 18px;
  font-weight: 700;
}

.hp-stepper .amount-input:focus {
  border-color: var(--gold);
}

/* --- 6.3 Death Saves --- */
.death-saves {
  display: none;
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--red);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.death-saves.visible {
  display: block;
  animation: fade-in 0.3s ease;
}

.death-saves .saves-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.death-saves .saves-label {
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.death-saves .saves-label.successes { color: var(--green-bright); }
.death-saves .saves-label.failures  { color: var(--red-bright); }

.death-saves .saves-dots {
  display: flex;
  gap: var(--space-sm);
}

.death-saves .save-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(67, 56, 45, 0.5);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.death-saves .save-dot.success-marked {
  border-color: var(--green-bright);
  background: var(--green-bright);
  box-shadow: 0 0 6px rgba(94, 163, 80, 0.4);
}

.death-saves .save-dot.failure-marked {
  border-color: var(--red-bright);
  background: var(--red-bright);
  box-shadow: 0 0 6px rgba(212, 80, 62, 0.4);
}

/* --- 6.4 Weapons List --- */
.weapons-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.weapon-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 44px;
}

.weapon-item .weapon-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--gold-dim);
  background: rgba(29, 26, 22, 0.5);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.weapon-item .weapon-info {
  flex: 1;
  min-width: 0;
}

.weapon-item .weapon-name {
  font-family: var(--font-header);
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-item .weapon-stats {
  font-size: 12px;
  color: var(--text-secondary);
}

.weapon-item .weapon-stats .attack-bonus {
  color: var(--gold);
  font-weight: 600;
}

.weapon-item .weapon-stats .damage {
  color: var(--red-bright);
}

/* --- 6.5 Spells Section --- */
.spell-level-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-md);
  scrollbar-width: none;
  padding-bottom: 2px;
}

.spell-level-tabs::-webkit-scrollbar { display: none; }

.spell-level-tab {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-header);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.5), rgba(35, 29, 23, 0.6));
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all var(--transition);
  min-height: 32px;
}

.spell-level-tab.active {
  background: rgba(221, 162, 60, 0.1);
  border-color: rgba(163, 92, 41, 0.5);
  color: var(--gold);
}

.spell-slots {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: var(--space-md);
}

.spell-slot-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--purple);
  background: transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.spell-slot-dot.used {
  border-color: rgba(67, 56, 45, 0.4);
  background: rgba(67, 56, 45, 0.4);
  opacity: 0.4;
}

.spell-slot-dot.available {
  background: var(--purple);
  box-shadow: 0 0 6px rgba(122, 77, 140, 0.4);
}

.spell-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.spell-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 44px;
}

.spell-item .spell-name {
  flex: 1;
  font-family: var(--font-header);
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spell-item .spell-school {
  font-size: 11px;
  color: var(--purple-bright);
  background: rgba(122, 77, 140, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.spell-item .spell-conc {
  font-size: 10px;
  color: var(--gold);
}

/* --- 6.6 Features Section --- */
.feature-filters {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.feature-filter-btn {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-family: var(--font-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: transparent;
  transition: all var(--transition);
}

.feature-filter-btn.active {
  color: var(--gold);
  border-color: rgba(163, 92, 41, 0.5);
  background: rgba(221, 162, 60, 0.06);
}

.feature-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-xs);
  min-height: 44px;
}

.feature-item .feature-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
}

.feature-item .feature-uses {
  font-family: var(--font-header);
  font-size: 12px;
  color: var(--gold);
  background: rgba(221, 162, 60, 0.08);
  border-radius: var(--radius);
  padding: 2px 8px;
  flex-shrink: 0;
}

/* --- 6.7 Skills List --- */
.skills-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.skill-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.5), rgba(35, 29, 23, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 44px;
}

.skill-item .skill-mod {
  font-family: var(--font-header);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 32px;
}

.skill-item .skill-mod.positive { color: var(--green-bright); }
.skill-item .skill-mod.negative { color: var(--red-bright); }

.skill-item .skill-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-item .proficiency-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-dim);
  flex-shrink: 0;
}

.skill-item .proficiency-dot proficient {
  background: var(--gold);
  border-color: var(--gold);
}

.skill-item .proficiency-dot.expertise {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 0 4px rgba(232, 185, 78, 0.5);
}

/* --- 6.8 Saves List --- */
.saves-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.save-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-xs);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.5), rgba(35, 29, 23, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 44px;
}

.save-item .save-name {
  font-family: var(--font-header);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.save-item .save-mod {
  font-family: var(--font-header);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.save-item .proficiency-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 2px;
  border: 1.5px solid var(--gold-dim);
}

.save-item .proficiency-dot.proficient {
  background: var(--gold);
  border-color: var(--gold);
}

/* --- 6.9 Rest Buttons --- */
.rest-buttons {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.rest-btn {
  flex: 1;
  padding: var(--space-md);
  border-radius: var(--radius);
  font-family: var(--font-header);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  min-height: 44px;
  transition: all var(--transition);
}

.rest-btn.short-rest {
  background: rgba(61, 107, 142, 0.08);
  border: 1px solid var(--blue);
  color: var(--blue-bright);
}

.rest-btn.short-rest:active {
  background: rgba(61, 107, 142, 0.15);
}

.rest-btn.long-rest {
  background: rgba(221, 162, 60, 0.08);
  border: 1px solid rgba(163, 92, 41, 0.5);
  color: var(--gold);
}

.rest-btn.long-rest:active {
  background: rgba(221, 162, 60, 0.15);
}

/* --- 6.10 Resources --- */
.resource-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-xs);
  min-height: 44px;
}

.resource-item .resource-name {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

.resource-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.resource-stepper .step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(29, 26, 22, 0.5);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  transition: all var(--transition);
}

.resource-stepper .step-btn:active {
  background: rgba(221, 162, 60, 0.08);
}

.resource-stepper .resource-value {
  font-family: var(--font-header);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  min-width: 36px;
  text-align: center;
}

/* --- 6.11 Collapsible Sections --- */
.section {
  margin-bottom: var(--space-lg);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  cursor: pointer;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.section-header .section-title {
  font-family: var(--font-header);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-header .section-chevron {
  color: var(--text-secondary);
  font-size: 12px;
  transition: transform 0.3s ease;
}

.section.collapsed .section-chevron {
  transform: rotate(-90deg);
}

.section-body {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  max-height: 2000px;
  opacity: 1;
}

.section.collapsed .section-body {
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.2s ease;
}

/* ============================================================
   7. MAP TAB
   ============================================================ */

.map-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  touch-action: none;
  margin-bottom: var(--space-lg);
}

.map-image {
  width: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.map-toolbar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.map-toolbar .map-tool-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.6), rgba(35, 29, 23, 0.7));
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}

.map-toolbar .map-tool-btn.active {
  border-color: rgba(163, 92, 41, 0.5);
  color: var(--gold);
  background: rgba(221, 162, 60, 0.06);
}

/* Compass overlay */
.compass-overlay {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: none;
}

.compass-overlay.visible {
  display: block;
}

.compass-dial {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto var(--space-md);
}

.compass-dir {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.9), rgba(35, 29, 23, 0.95));
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-header);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.compass-dir:hover,
.compass-dir:active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(221, 162, 60, 0.08);
}

/* 8 directions positioned around the dial center */
.compass-dir.n  { top: 0;   left: 50%;  transform: translateX(-50%); }
.compass-dir.ne { top: 14%; left: 72%; }
.compass-dir.e  { top: 50%; left: 80%;  transform: translateY(-50%); }
.compass-dir.se { top: 72%; left: 72%; }
.compass-dir.s  { top: 80%; left: 50%;  transform: translateX(-50%); }
.compass-dir.sw { top: 72%; left: 8%; }
.compass-dir.w  { top: 50%; left: 0;    transform: translateY(-50%); }
.compass-dir.nw { top: 14%; left: 8%; }

.compass-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.9), rgba(35, 29, 23, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.compass-controls select,
.compass-controls input[type="range"] {
  width: 100%;
}

.compass-controls .move-btn-row {
  display: flex;
  gap: var(--space-sm);
}

.compass-controls .move-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius);
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: var(--bg-deep);
  font-weight: 700;
  border: none;
  min-height: 44px;
}

/* Target overlay */
.target-overlay {
  display: none;
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  max-height: 240px;
  overflow-y: auto;
}

.target-overlay.visible {
  display: block;
}

.target-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.target-entry:last-child {
  border-bottom: none;
}

.target-entry .target-name {
  font-size: 14px;
  color: var(--text-primary);
}

.target-entry .target-distance {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-header);
}

/* Move indicator crosshair */
.move-indicator {
  position: absolute;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  display: none;
}

.move-indicator.visible {
  display: block;
  animation: crosshair-appear 0.2s ease;
}

.move-indicator::before,
.move-indicator::after {
  content: '';
  position: absolute;
  background: var(--gold);
}

.move-indicator::before {
  width: 2px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.move-indicator::after {
  width: 100%;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

@keyframes crosshair-appear {
  from { opacity: 0; transform: translate(-50%, -50%) scale(2); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ============================================================
   8. SETTINGS TAB
   ============================================================ */
.settings-card {
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.settings-card .settings-title {
  font-family: var(--font-header);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: var(--space-md);
}

.world-discover-btn {
  width: 100%;
  margin-bottom: var(--space-md);
}

.world-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.world-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: rgba(29, 26, 22, 0.5);
  border-radius: var(--radius);
  font-size: 13px;
}

.world-entry .world-name {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-entry .world-connect-btn {
  font-size: 11px;
  color: var(--gold);
  padding: 4px 10px;
  border: 1px solid rgba(163, 92, 41, 0.4);
  border-radius: var(--radius-pill);
  background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.pwa-install-btn {
  width: 100%;
  margin-bottom: var(--space-md);
}

.cache-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.cache-clear-btn {
  width: 100%;
}

/* ============================================================
   9. BOTTOM SHEETS (Slide-up Modals)
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.visible {
  display: block;
  opacity: 1;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: linear-gradient(to top, rgba(35, 29, 23, 0.98), rgba(43, 36, 29, 0.95));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid rgba(67, 56, 45, 0.5);
  border-left: 1px solid rgba(67, 56, 45, 0.5);
  border-right: 1px solid rgba(67, 56, 45, 0.5);
  z-index: 210;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: var(--space-xl);
  padding-bottom: calc(var(--space-xl) + var(--safe-bottom));
}

.bottom-sheet.visible {
  transform: translateY(0);
}

.bottom-sheet .sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(67, 56, 45, 0.5);
  border-radius: 2px;
  margin: 0 auto var(--space-lg);
}

/* Roll mode prompt sheet */
.roll-sheet .roll-mode-buttons {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.roll-mode-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  border-radius: var(--radius);
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 2px solid rgba(67, 56, 45, 0.4);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
  min-height: 44px;
}

.roll-mode-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(221, 162, 60, 0.06);
}

.roll-mode-btn.disadvantage.active {
  border-color: var(--red);
  color: var(--red-bright);
  background: rgba(166, 61, 47, 0.06);
}

.roll-mode-btn.advantage.active {
  border-color: var(--green);
  color: var(--green-bright);
  background: rgba(74, 124, 63, 0.06);
}

.roll-sheet .bonus-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.roll-sheet .bonus-label {
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.roll-sheet .bonus-input {
  width: 60px;
  text-align: center;
  padding: 8px;
  background: rgba(29, 26, 22, 0.5);
  border: 1px solid rgba(67, 56, 45, 0.6);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-header);
  font-size: 16px;
}

.roll-sheet .bonus-input:focus {
  border-color: var(--gold);
}

.roll-sheet .roll-actions {
  display: flex;
  gap: var(--space-md);
}

/* Damage number popup (RPG float-up) */
.damage-popup {
  position: fixed;
  font-family: var(--font-header);
  font-weight: 900;
  font-size: 36px;
  color: var(--red-bright);
  text-shadow:
    0 0 10px rgba(212, 80, 62, 0.5),
    0 2px 4px rgba(0,0,0,0.8),
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  pointer-events: none;
  z-index: 300;
  animation: damage-float 1.5s ease-out forwards;
}

.damage-popup.heal {
  color: var(--green-bright);
  text-shadow:
    0 0 10px rgba(94, 163, 80, 0.5),
    0 2px 4px rgba(0,0,0,0.8),
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

/* ============================================================
   10. OVERLAYS
   ============================================================ */

/* --- 10.1 Backdrop --- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: none;
}

.overlay-backdrop.visible {
  display: block;
  animation: fade-in 0.2s ease;
}

/* --- 10.2 Loading Spinner --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  background: rgba(29, 26, 22, 0.85);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(67, 56, 45, 0.4);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner.small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

/* --- 10.3 Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + var(--space-sm));
  right: var(--space-lg);
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 320px;
  pointer-events: none;
}

.toast {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.95), rgba(35, 29, 23, 0.98));
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  font-size: 13px;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.leaving {
  opacity: 0;
  transform: translateX(100%);
}

.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--blue); }
.toast.warning { border-color: #c47a2b; }

.toast .toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--green-bright); }
.toast.error   .toast-icon { color: var(--red-bright); }
.toast.info    .toast-icon { color: var(--blue-bright); }
.toast.warning .toast-icon { color: #d4922f; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- 10.4 Sheet View (Full character sheet image) --- */
.sheet-viewer {
  position: fixed;
  inset: 0;
  z-index: 550;
  background: rgba(0,0,0,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.sheet-viewer.visible {
  display: flex;
}

.sheet-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
}

.sheet-viewer .close-btn {
  position: absolute;
  top: calc(var(--safe-top) + var(--space-lg));
  right: var(--space-lg);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.9), rgba(35, 29, 23, 0.95));
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   11. VISUAL FEEDBACK ANIMATIONS
   ============================================================ */

/* damage-flash: red vignette pulse 1.5s */
@keyframes damage-flash {
  0%   { box-shadow: inset 0 0 0 0 rgba(166, 61, 47, 0); }
  30%  { box-shadow: inset 0 0 80px 20px rgba(166, 61, 47, 0.6); }
  100% { box-shadow: inset 0 0 0 0 rgba(166, 61, 47, 0); }
}

.damage-flash {
  animation: damage-flash 1.5s ease-out;
}

/* heal-glow: green shimmer 1.0s */
@keyframes heal-glow {
  0%   { box-shadow: 0 0 0 0 rgba(94, 163, 80, 0); }
  40%  { box-shadow: 0 0 30px 8px rgba(94, 163, 80, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(94, 163, 80, 0); }
}

.heal-glow {
  animation: heal-glow 1.0s ease-out;
}

/* temp-hp-glow: blue outline 0.8s */
@keyframes temp-hp-glow {
  0%   { box-shadow: 0 0 0 0 rgba(77, 141, 176, 0); }
  50%  { box-shadow: 0 0 16px 4px rgba(77, 141, 176, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(77, 141, 176, 0); }
}

.temp-hp-glow {
  animation: temp-hp-glow 0.8s ease-out;
}

/* condition-enter: bounce-in with red tint 0.8s */
@keyframes condition-enter {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; background-color: rgba(166, 61, 47, 0.2); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); background-color: transparent; }
}

.condition-enter {
  animation: condition-enter 0.8s ease;
}

/* condition-exit: fade with green check 0.6s */
@keyframes condition-exit {
  0%   { opacity: 1; transform: scale(1); }
  50%  { opacity: 0.7; transform: scale(1.05); background-color: rgba(94, 163, 80, 0.2); }
  100% { opacity: 0; transform: scale(0.8); }
}

.condition-exit {
  animation: condition-exit 0.6s ease forwards;
}

/* screen-shake: translateX oscillation 0.5s */
@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  10%  { transform: translateX(-8px); }
  20%  { transform: translateX(8px); }
  30%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  50%  { transform: translateX(-4px); }
  60%  { transform: translateX(4px); }
  70%  { transform: translateX(-2px); }
  80%  { transform: translateX(2px); }
  90%  { transform: translateX(-1px); }
}

.screen-shake {
  animation: screen-shake 0.5s ease;
}

/* turn-glow: golden border pulse infinite */
@keyframes turn-glow {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(221, 162, 60, 0.3), inset 0 0 4px 1px rgba(221, 162, 60, 0.05); border-color: var(--gold-dim); }
  50%      { box-shadow: 0 0 16px 4px rgba(221, 162, 60, 0.5), inset 0 0 8px 2px rgba(221, 162, 60, 0.1); border-color: var(--gold-bright); }
}

.turn-glow {
  animation: turn-glow 2s ease-in-out infinite;
  border: 2px solid var(--gold-dim);
}

/* downed-pulse: greyscale + red overlay infinite */
@keyframes downed-pulse {
  0%, 100% { filter: grayscale(0.8) brightness(0.6); box-shadow: inset 0 0 20px rgba(166, 61, 47, 0.2); }
  50%      { filter: grayscale(1) brightness(0.4); box-shadow: inset 0 0 40px rgba(166, 61, 47, 0.5); }
}

.downed-pulse {
  animation: downed-pulse 2s ease-in-out infinite;
}

/* damage-float: float up + fade + scale 1.5s */
@keyframes damage-float {
  0%   { opacity: 1; transform: translateY(0) scale(0.8); }
  20%  { opacity: 1; transform: translateY(-20px) scale(1.3); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.9); }
}

/* purple-flash: concentration break 1.2s */
@keyframes purple-flash {
  0%   { box-shadow: 0 0 0 0 rgba(122, 77, 140, 0); }
  30%  { box-shadow: 0 0 40px 10px rgba(122, 77, 140, 0.6); }
  60%  { box-shadow: 0 0 20px 5px rgba(122, 77, 140, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(122, 77, 140, 0); }
}

.purple-flash {
  animation: purple-flash 1.2s ease-out;
}

/* ============================================================
   12. CONDITION PORTRAIT OVERLAYS
   ============================================================ */

/* Concentrating: gold aura ring + pulse */
.portrait-wrap.concentrating .portrait {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(221, 162, 60, 0.35);
}

.portrait-wrap.concentrating .portrait-overlay {
  box-shadow:
    0 0 15px 3px rgba(221, 162, 60, 0.25),
    inset 0 0 15px 3px rgba(221, 162, 60, 0.08);
  animation: conc-aura 2s ease-in-out infinite;
}

@keyframes conc-aura {
  0%, 100% { box-shadow: 0 0 10px 2px rgba(221, 162, 60, 0.18), inset 0 0 10px 2px rgba(221, 162, 60, 0.06); }
  50%      { box-shadow: 0 0 20px 5px rgba(221, 162, 60, 0.45), inset 0 0 20px 5px rgba(221, 162, 60, 0.12); }
}

/* Invisible: opacity 0.15 + shimmer */
.portrait-wrap.invisible .portrait {
  opacity: 0.15;
  animation: invis-shimmer 3s ease-in-out infinite;
}

@keyframes invis-shimmer {
  0%, 100% { opacity: 0.1; }
  50%      { opacity: 0.25; }
}

.portrait-wrap.invisible .portrait-overlay {
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
}

/* Prone: rotate */
.portrait-wrap.prone .portrait {
  transform: rotate(-80deg);
  border-style: dashed;
}

/* Poisoned: green drip gradient overlay */
.portrait-wrap.poisoned .portrait-overlay {
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(94, 163, 80, 0.15) 50%,
    rgba(94, 163, 80, 0.4) 85%,
    rgba(94, 163, 80, 0.6) 100%);
  animation: poison-drip 2s ease-in-out infinite;
}

@keyframes poison-drip {
  0%, 100% { background-position: 0 0; }
  50%      { background-position: 0 4px; }
}

.portrait-wrap.poisoned .portrait {
  border-color: var(--green);
  filter: hue-rotate(-10deg) saturate(0.8);
}

/* Burning: flame gradient + flicker */
.portrait-wrap.burning .portrait-overlay {
  background: linear-gradient(0deg,
    rgba(196, 122, 43, 0.5) 0%,
    rgba(212, 146, 47, 0.3) 40%,
    rgba(232, 185, 78, 0.1) 70%,
    transparent 100%);
  animation: flame-flicker 0.4s ease-in-out infinite alternate;
}

@keyframes flame-flicker {
  0%   { opacity: 0.7; background-position: 0 0; }
  100% { opacity: 1; background-position: 0 -3px; }
}

.portrait-wrap.burning .portrait {
  border-color: #c47a2b;
  box-shadow: 0 0 10px rgba(196, 122, 43, 0.4);
}

/* Frozen: blue tint + blur */
.portrait-wrap.frozen .portrait-overlay {
  background: radial-gradient(circle, rgba(61, 107, 142, 0.25) 0%, rgba(61, 107, 142, 0.4) 100%);
}

.portrait-wrap.frozen .portrait {
  filter: blur(1px) brightness(0.85) saturate(0.5) sepia(0.3) hue-rotate(180deg);
  border-color: var(--blue);
  box-shadow: 0 0 8px rgba(61, 107, 142, 0.3);
}

.portrait-wrap.frozen .portrait-overlay::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1px solid rgba(61, 107, 142, 0.3);
}

/* Blinded: black radial vignette */
.portrait-wrap.blinded .portrait-overlay {
  background: radial-gradient(circle,
    transparent 20%,
    rgba(0,0,0,0.3) 50%,
    rgba(0,0,0,0.8) 75%,
    rgba(0,0,0,0.95) 100%);
}

.portrait-wrap.blinded .portrait {
  filter: brightness(0.5);
  border-color: #6b6256;
}

/* Charmed: purple mist + rotation */
.portrait-wrap.charmed .portrait-overlay {
  background: radial-gradient(circle,
    rgba(122, 77, 140, 0.2) 0%,
    rgba(122, 77, 140, 0.4) 60%,
    transparent 100%);
  animation: charm-mist 3s ease-in-out infinite;
}

@keyframes charm-mist {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.7; }
  50%      { transform: rotate(5deg) scale(1.05); opacity: 1; }
}

.portrait-wrap.charmed .portrait {
  border-color: var(--purple);
  animation: charm-swirl 4s linear infinite;
}

@keyframes charm-swirl {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(15deg); }
}

/* Frightened: shadow + subtle shake */
.portrait-wrap.frightened .portrait-overlay {
  background: linear-gradient(180deg,
    rgba(0,0,0,0.5) 0%,
    rgba(122, 77, 140, 0.15) 50%,
    transparent 100%);
}

.portrait-wrap.frightened .portrait {
  animation: fear-shake 0.3s ease-in-out infinite;
  border-color: #6b3d7a;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

@keyframes fear-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-1px); }
  75%      { transform: translateX(1px); }
}

/* Restrained: grey diagonal stripes */
.portrait-wrap.restrained .portrait-overlay {
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(149,165,166,0.3) 4px,
    rgba(149,165,166,0.3) 6px
  );
}

.portrait-wrap.restrained .portrait {
  filter: grayscale(0.4) brightness(0.8);
  border-color: #7a7058;
}

/* ============================================================
   13. HP BAR (Detailed)
   ============================================================ */
.hp-bar-section {
  margin-bottom: var(--space-lg);
}

.hp-bar-outer {
  position: relative;
  height: 14px;
  background: rgba(29, 26, 22, 0.8);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.hp-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: calc(var(--radius) - 1px);
  transition: width 0.5s ease, background 0.5s ease;
}

.hp-bar-fill.health-green {
  background: linear-gradient(90deg, #3a6b32 0%, var(--green-bright) 100%);
}

.hp-bar-fill.health-yellow {
  background: linear-gradient(90deg, #8a6d1b 0%, #c4a626 100%);
}

.hp-bar-fill.health-red {
  background: linear-gradient(90deg, #6b2a22 0%, var(--red-bright) 100%);
}

.hp-bar-temp {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(61, 107, 142, 0.5), var(--blue-bright));
  border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0;
  transition: width 0.5s ease;
}

.hp-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-header);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  z-index: 2;
  pointer-events: none;
}

/* ============================================================
   14. RESPONSIVE & UTILITIES
   ============================================================ */

/* --- Auth screen #auth-screen specific --- */
#auth-screen {
  overflow-y: auto;
}

/* Generic card */
.card {
  background: linear-gradient(145deg, rgba(43, 36, 29, 0.8), rgba(35, 29, 23, 0.9));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.card h3 {
  font-family: var(--font-header);
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: var(--space-md);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 32px;
  color: rgba(67, 56, 45, 0.5);
  margin-bottom: var(--space-md);
}

.empty-state p {
  font-size: 14px;
}

/* Connection dot */
.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 6px rgba(94, 163, 80, 0.5);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.conn-dot.disconnected {
  background: var(--red-bright);
  box-shadow: 0 0 6px rgba(212, 80, 62, 0.5);
}

.conn-dot.connecting {
  background: var(--gold);
  animation: pulse-dot 1.2s infinite alternate;
}

/* Muted text */
.text2 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* Back button */
.btn-back {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.btn-back:hover {
  color: var(--gold);
}

/* API key display row */
.apikey-display {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.apikey-display input {
  flex: 1;
  min-width: 0;
}

/* --- 14.1 Mobile readability fixes --- */
/* Raise minimum font sizes so text is always readable without zooming */
.ability-item .ability-name,
.condition-chip,
.action-toggle span,
.save-dot span,
.spell-slot-label,
.chip-remove,
.text2 {
  font-size: 12px;
}

.ability-item .ability-mod,
.actor-card .actor-class,
.actor-card .ac-badge,
.hp-display .temp-hp-line,
.auth-step-dot,
.step-dot,
.auth-subtitle,
.auth-detail,
.auth-help {
  font-size: 13px;
}

#tabbar button span,
.auth-card label,
#auth-screen label,
.form-group label {
  font-size: 12px;
  letter-spacing: 0.8px;
}

/* Prevent iOS auto-zoom: all text inputs must be >= 16px */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  font-size: 16px !important;
}

/* Tab bar — larger touch targets and text on mobile */
#tabbar button {
  min-height: 56px;
  padding: 6px 0;
}

#tabbar button i {
  font-size: 22px;
}

#tabbar button span {
  font-size: 10px;
}

/* HP bar text needs to be readable */
.hp-bar .hp-text {
  font-size: 11px;
}

/* Portrait sizes — slightly larger on mobile */
.actor-card .portrait {
  width: 52px;
  height: 52px;
}

.portrait-wrap {
  width: 88px;
  height: 88px;
}

/* --- 14.2 Small phone (≥360px) --- */
@media (min-width: 360px) {
  #tabbar button span {
    font-size: 11px;
  }

  .ability-item .ability-name {
    font-size: 11px;
  }

  .ability-item .ability-mod {
    font-size: 14px;
  }
}

/* --- 14.3 Medium phone / landscape (≥480px) --- */
@media (min-width: 480px) {
  .ability-grid {
    gap: var(--space-md);
  }

  .skills-list {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .saves-list {
    grid-template-columns: repeat(6, 1fr);
  }

  #tabbar button span {
    font-size: 12px;
  }
}

/* --- 14.4 Tablet portrait (≥768px) --- */
@media (min-width: 768px) {
  .content {
    max-width: 600px;
    margin: 0 auto;
  }

  .actor-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .ability-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-md);
  }

  .ability-item .ability-name {
    font-size: 12px;
  }

  .ability-item .ability-score {
    font-size: 26px;
  }

  .toast-container {
    right: var(--space-2xl);
  }
}

/* --- 14.5 Desktop / wide tablet (≥1024px) --- */
@media (min-width: 1024px) {
  :root {
    --header-h: 56px;
    --tabbar-h: 64px;
  }

  /* App shell: wider, with sidebar-style desktop nav */
  #app {
    max-width: 100%;
  }

  .content {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-2xl);
  }

  /* Header: bigger title */
  .header h1, #header h1 {
    font-size: 22px;
  }

  /* Tab bar: wider, more spacious */
  #tabbar {
    height: calc(var(--tabbar-h) + var(--safe-bottom));
  }

  #tabbar button {
    min-height: var(--tabbar-h);
  }

  #tabbar button span {
    font-size: 13px;
  }

  #tabbar button i {
    font-size: 24px;
  }

  /* Actor details: side-by-side layout */
  .actor-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  /* Auth card: wider on desktop */
  .auth-wrapper,
  .auth-card {
    max-width: 480px;
  }

  /* Selected actor card: horizontal layout */
  .selected-actor .actor-top {
    flex-wrap: nowrap;
  }

  /* Portrait larger on desktop */
  .portrait-wrap {
    width: 100px;
    height: 100px;
  }

  .actor-card .portrait {
    width: 56px;
    height: 56px;
  }

  /* Cards more spacious */
  .card {
    padding: var(--space-2xl);
  }

  /* Map container: more usable */
  .map-container {
    max-height: 60vh;
  }

  /* Ability grid: full 6-column layout */
  .ability-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-lg);
  }

  /* Combat controls: wider */
  .hp-controls {
    padding: var(--space-xl);
  }

  .hp-display .hp-current {
    font-size: 56px;
  }

  .hp-display .hp-max {
    font-size: 28px;
  }

  /* Skills: wider columns */
  .skills-list {
    grid-template-columns: 1fr 1fr 1fr;
  }

  /* Bottom sheets: wider */
  .bottom-sheet {
    max-width: 540px;
    margin: 0 auto;
  }

  /* Buttons bigger on desktop */
  .btn {
    padding: 14px 24px;
    font-size: 15px;
  }

  .btn-sm {
    padding: 10px 18px;
    font-size: 13px;
    min-height: 40px;
  }

  /* Action toggles wider */
  .action-toggle {
    padding: var(--space-md) var(--space-sm);
    font-size: 13px;
  }

  .action-toggle i {
    font-size: 22px;
  }
}

/* --- 14.6 Large desktop (≥1440px) --- */
@media (min-width: 1440px) {
  .content {
    max-width: 960px;
  }

  .auth-wrapper,
  .auth-card {
    max-width: 520px;
  }

  .actor-list {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .ability-grid {
    gap: var(--space-xl);
  }
}

/* --- 14.2 Minimum touch targets --- */
button,
[role="button"],
input,
select,
textarea,
.tap-target {
  min-height: 44px;
  min-width: 44px;
}

/* Small controls that still need a 44px tap area */
.chip-tap-area,
.save-dot,
.spell-slot-dot {
  position: relative;
}

.chip-tap-area::before,
.save-dot::before,
.spell-slot-dot::before {
  content: '';
  position: absolute;
  inset: -8px;
}

/* --- 14.3 Safe-area-inset --- */
#app {
  padding-top: var(--safe-top);
}

.content {
  padding-left: max(var(--space-lg), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-lg), env(safe-area-inset-right, 0px));
}

/* --- 14.4 Prevent horizontal overflow --- */
html, body, #app, .content {
  overflow-x: hidden;
  max-width: 100vw;
}

img, canvas, svg, video {
  max-width: 100%;
}

/* --- 14.5 Smooth scrolling --- */
.content,
.scrollable {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* --- 14.6 Utility classes --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.text-gold   { color: var(--gold); }
.text-red    { color: var(--red-bright); }
.text-green  { color: var(--green-bright); }
.text-blue   { color: var(--blue-bright); }
.text-purple { color: var(--purple-bright); }
.text-muted  { color: var(--text-secondary); }
.text-error  { color: var(--red-bright); }

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-xs  { gap: var(--space-xs); }
.gap-sm  { gap: var(--space-sm); }
.gap-md  { gap: var(--space-md); }
.gap-lg  { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* --- 14.7 Selection & focus styles --- */
::selection {
  background: rgba(221, 162, 60, 0.3);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* --- 14.8 Print / PWA standalone adjustments --- */
@media all and (display-mode: standalone) {
  .pwa-hide {
    display: none !important;
  }

  .header {
    padding-top: max(var(--space-sm), var(--safe-top));
  }
}

/* --- 14.9 Prefers-reduced-motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- 14.10a Auth actor selection cards --- */
.auth-actor-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  max-height: 55vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-actor-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(145deg, rgba(43,36,29,0.7), rgba(35,29,23,0.8));
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.auth-actor-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent-gold);
  background: linear-gradient(145deg, rgba(50,42,34,0.8), rgba(43,36,29,0.9));
}

.auth-actor-card:active {
  transform: translateY(0);
  background: linear-gradient(145deg, rgba(55,46,37,0.9), rgba(47,39,31,0.95));
}

.auth-actor-portrait {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-deep);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-actor-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.auth-actor-portrait i {
  color: var(--text-muted);
  font-size: 20px;
}

.auth-actor-info {
  flex: 1;
  min-width: 0;
}

.auth-actor-name {
  font-family: var(--font-header);
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-actor-sub {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-actor-arrow {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  transition: color 0.2s ease, transform 0.15s ease;
}

.auth-actor-card:hover .auth-actor-arrow {
  color: var(--accent-gold);
  transform: translateX(2px);
}

/* --- 14.10b Prefers-color-scheme (future light mode placeholder) --- */
@media (prefers-color-scheme: light) {
  /* Dark fantasy theme is intentional; no light override */
}

/* --- 14.11 Mobile auth form size boost (phones < 480px) --- */
@media (max-width: 479px) {
  .auth-logo h1 {
    font-size: 44px;
  }
  .auth-logo i {
    font-size: 80px;
  }
  .auth-subtitle {
    font-size: 20px;
  }
  #auth-screen h3,
  .auth-step h3 {
    font-size: 32px;
  }
  .auth-help {
    font-size: 19px;
  }
  .form-group label,
  #auth-screen label {
    font-size: 17px;
  }
  .form-input,
  .auth-card input[type="text"],
  .auth-card input[type="email"],
  .auth-card input[type="password"],
  .auth-card input[type="number"],
  .auth-card select,
  #auth-screen input[type="text"],
  #auth-screen input[type="email"],
  #auth-screen input[type="password"],
  #auth-screen input[type="number"],
  #auth-screen select {
    padding: 18px 20px;
    font-size: 20px;
    border-radius: 12px;
  }
  .btn {
    padding: 20px 28px;
    font-size: 20px;
    min-height: 64px;
    border-radius: 12px;
  }
  .btn-ghost {
    padding: 16px 20px;
    font-size: 18px;
  }
  .auth-divider {
    margin: var(--space-2xl) 0;
  }
  .auth-steps {
    gap: var(--space-xl);
  }
  .auth-step-dot,
  .step-dot {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .auth-steps .step-line {
    width: 48px;
  }
  .form-group {
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
  }
  .auth-errors {
    font-size: 16px;
  }
  #auth-screen {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  /* Auth actor cards bigger on mobile */
  .auth-actor-portrait {
    width: 56px;
    height: 56px;
  }
  .auth-actor-portrait i {
    font-size: 24px;
  }
  .auth-actor-name {
    font-size: 18px;
  }
  .auth-actor-sub {
    font-size: 15px;
  }
  .auth-actor-card {
    padding: var(--space-lg) var(--space-lg);
  }
  .auth-actor-arrow {
    font-size: 18px;
  }
}

/* ============================================================
   END OF STYLESHEET
   ============================================================ */