﻿/* ==========================================================================
   Table Companion — Frosted Glassmorphism Mobile Design System
   ========================================================================== */

:root {
  --bg-base: #0a0c12;
  --bg-gradient: radial-gradient(circle at 50% 0%, #171c2b 0%, #0a0c12 70%);
  
  --glass-surface: rgba(22, 27, 40, 0.72);
  --glass-surface-elevated: rgba(30, 37, 56, 0.85);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-bright: rgba(255, 255, 255, 0.18);
  --glass-blur: blur(16px);

  --text-primary: #f8fafc;
  --text-secondary: rgba(248, 250, 252, 0.65);
  --text-muted: rgba(248, 250, 252, 0.4);

  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.35);
  --yellow: #f59e0b;
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.35);
  --blue: #3b82f6;
  --indigo: #6366f1;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-base);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
}

/* ==========================================================================
   Base Glass Elements & Typography
   ========================================================================== */

.glass-card {
  background: var(--glass-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  padding: 16px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 90px;
}

.empty-notice {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-style: italic;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */

button {
  border: 1px solid var(--glass-border);
  background: var(--glass-surface-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: var(--gold-gradient);
  color: #1a1001;
  font-weight: 700;
  border: none;
  box-shadow: 0 4px 14px 0 var(--gold-glow);
}

.btn-primary:active {
  box-shadow: 0 2px 6px 0 var(--gold-glow);
}

.btn-mini {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
}

input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: rgba(10, 12, 18, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

/* ==========================================================================
   Connection Screen
   ========================================================================== */

.screen.connect {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
}

.connect-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 28px 20px;
}

.brand-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}

.connect-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 4px 0;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.connect-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.field-group {
  text-align: left;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.pin-input {
  height: 56px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.45);
}

.btn-connect {
  width: 100%;
  height: 52px;
  font-size: 1.1rem;
  margin-top: 12px;
}

.connect-status {
  min-height: 24px;
  margin: 12px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.advanced-toggle {
  text-align: left;
  margin: 12px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Character Header Vitals
   ========================================================================== */

.glass-header {
  background: var(--glass-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border-bright);
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.char-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.char-name {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conn-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.conn-indicator.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.conn-indicator.offline {
  background: var(--red);
}

.stat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-chip {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
}

.badge-turn {
  background: var(--gold-gradient);
  color: #1a1001;
  font-weight: 800;
  animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
  from { box-shadow: 0 0 4px var(--gold-glow); }
  to { box-shadow: 0 0 12px var(--gold-glow); }
}

/* HP Section */
.hp-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-btn {
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.hp-track {
  flex: 1;
  height: 28px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hp-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hp-track[data-band="bloodied"] .hp-fill {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.hp-track[data-band="critical"] .hp-fill {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.hp-track[data-band="unconscious"] .hp-fill {
  background: linear-gradient(90deg, #6b7280 0%, #4b5563 100%);
}

.hp-label {
  position: relative;
  z-index: 2;
  font-size: 0.85rem;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.conditions-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.condition-pill {
  padding: 3px 10px;
  font-size: 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ==========================================================================
   Action Economy & Strikes (Act Tab)
   ========================================================================== */

.action-economy-card {
  text-align: center;
}

.action-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.action-section-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.action-bubbles-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 6px;
}

.action-orb {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 800;
  border: 2px solid var(--glass-border-bright);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-orb.active {
  background: var(--gold-gradient);
  color: #1a1001;
  border-color: #fef08a;
  box-shadow: 0 0 20px var(--gold-glow);
  transform: translateY(-2px);
}

.strike-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
}

.strike-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.strike-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.strike-dmg-formula {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.variants-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-strike-variant {
  flex: 1;
  min-width: 80px;
  height: 44px;
  font-size: 0.95rem;
  background: var(--glass-surface-elevated);
}

.btn-damage {
  height: 44px;
  padding: 0 16px;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  border: none;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.skill-chip {
  height: 40px;
  font-size: 0.85rem;
  justify-content: space-between;
  padding: 0 12px;
}

/* ==========================================================================
   Inventory Tab (Inv Tab)
   ========================================================================== */

.bulk-numeric {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
}

.bulk-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 16px;
}

.bulk-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
}

.bulk-fill.bulk-warning { background: var(--yellow); }
.bulk-fill.bulk-over { background: var(--red); }

.coin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.coin-chip {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
}

.coin-amount {
  font-size: 1.15rem;
  font-weight: 800;
}

.coin-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.coin-pp .coin-amount { color: #e0e7ff; }
.coin-gp .coin-amount { color: #facc15; }
.coin-sp .coin-amount { color: #cbd5e1; }
.coin-cp .coin-amount { color: #f97316; }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #000;
  object-fit: cover;
  flex-shrink: 0;
}

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

.item-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta-row {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-equip {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-pill);
}

.btn-equip.active {
  background: var(--green);
  color: #022c22;
  border-color: var(--green);
}

.btn-use {
  padding: 6px 14px;
  font-size: 0.8rem;
  background: var(--indigo);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Movement & Tactical D-Pad (Move Tab)
   ========================================================================== */

.speed-summary-card {
  text-align: center;
}

.speed-grid {
  display: flex;
  justify-content: center;
}

.main-speed {
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
}

.speed-icon { font-size: 1.8rem; margin-bottom: 2px; }
.speed-value { font-size: 2rem; font-weight: 800; color: var(--gold); }
.speed-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

.dpad-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

.dpad-title {
  margin-bottom: 20px;
}

.tactical-dpad {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.dpad-row {
  display: flex;
  gap: 10px;
}

.dpad-btn {
  width: 68px;
  height: 68px;
  font-size: 1.6rem;
  border-radius: var(--radius-lg);
  background: var(--glass-surface-elevated);
  border: 1px solid var(--glass-border-bright);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dpad-cardinal {
  background: rgba(45, 55, 80, 0.9);
  color: var(--gold);
}

.dpad-diag {
  background: rgba(25, 30, 45, 0.75);
  color: var(--text-muted);
  font-size: 1.3rem;
}

.dpad-center {
  background: var(--gold-gradient);
  color: #1a1001;
  font-size: 1.6rem;
  border: none;
  box-shadow: 0 0 16px var(--gold-glow);
}

.dpad-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Combat & Initiative (Fray Tab)
   ========================================================================== */

.turn-banner {
  background: var(--gold-gradient);
  color: #1a1001;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}

.turn-banner-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.turn-banner-sub {
  font-size: 0.8rem;
  opacity: 0.85;
}

.btn-end-turn {
  background: #1a1001;
  color: var(--gold);
  border: 1px solid rgba(0,0,0,0.4);
  padding: 8px 16px;
}

.round-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
}

.init-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}

.init-row.current-turn {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--gold);
  box-shadow: 0 0 14px var(--gold-glow);
}

.init-score {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.init-name-col {
  flex: 1;
}

.init-name {
  font-weight: 700;
}

.init-current-tag {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gold);
}

.init-pointer {
  color: var(--gold);
  font-size: 1.2rem;
}

/* ==========================================================================
   Chat & Dice (Chat Tab)
   ========================================================================== */

.chat-feed-card {
  max-height: 420px;
  display: flex;
  flex-direction: column;
}

.feed-stream {
  overflow-y: auto;
  flex: 1;
}

.chat-msg {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 8px;
}

.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.msg-speaker {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gold);
}

.msg-total-badge {
  font-size: 1rem;
  font-weight: 800;
  padding: 2px 8px;
  background: var(--gold-gradient);
  color: #1a1001;
  border-radius: var(--radius-pill);
}

.msg-flavor {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.msg-body {
  font-size: 0.9rem;
}

.dice-controls-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.dice-input-box {
  flex: 1;
}

.input-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.dice-num-input {
  height: 40px;
  text-align: center;
  font-weight: 700;
}

.dice-buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.btn-die {
  height: 44px;
  font-size: 1rem;
  font-weight: 800;
}

/* ==========================================================================
   Floating Frosted Glass Bottom Navigation
   ========================================================================== */

.glass-nav {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 10px);
  left: 12px;
  right: 12px;
  height: 64px;
  background: rgba(18, 22, 34, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 8px;
  z-index: 100;
}

.nav-tab-btn {
  flex: 1;
  height: 52px;
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.nav-tab-btn.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold);
}

.nav-tab-btn.active .nav-icon {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

.turn-badge-pulse {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: badge-pulse 1s infinite alternate;
}

@keyframes badge-pulse {
  from { transform: scale(0.8); opacity: 0.6; }
  to { transform: scale(1.3); opacity: 1; }
}

/* Toast Messages */
.toast {
  position: fixed;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border-bright);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  pointer-events: none;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
