/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* === DARK MODE (default) === */
  --bg:         #060e1c;
  --bg2:        #0b1628;
  --bg3:        #0f1e38;
  --panel:      #101e36;
  --panel2:     #142440;
  --border:     #1e3558;
  --border-hi:  #2e5280;

  --ice:        #60c8f0;
  --ice-dim:    #3aa0d0;
  --ice-glow:   rgba(96,200,240,0.15);
  --ice-light:  rgba(96,200,240,0.08);

  --gold:       #f0c040;
  --gold-dim:   #c89820;
  --gold-bg:    rgba(240,192,64,0.12);

  --green:      #00f090;
  --green-dim:  #00c070;
  --green-bg:   rgba(0,240,144,0.10);

  --red:        #ff3355;
  --red-dim:    #cc1133;
  --red-bg:     rgba(255,51,85,0.12);

  --orange:     #ff8c00;
  --orange-bg:  rgba(255,140,0,0.12);

  --yellow:     #ffd060;
  --yellow-bg:  rgba(255,208,96,0.12);

  --text:       #d8eeff;
  --text-dim:   #6090b8;
  --text-muted: #304868;

  --shadow:     0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);

  --font-display: 'Exo 2', sans-serif;
  --font-mono:    'Share Tech Mono', monospace;
  --font-ui:      'Rajdhani', sans-serif;
  --radius:       8px;
  --radius-lg:    14px;
}

/* === LIGHT MODE === */
body.light-mode {
  --bg:         #e8f4fd;
  --bg2:        #f4faff;
  --bg3:        #ffffff;
  --panel:      #ffffff;
  --panel2:     #f0f8ff;
  --border:     #b8d8f0;
  --border-hi:  #70b0d8;

  --ice:        #1a7abf;
  --ice-dim:    #2090d8;
  --ice-glow:   rgba(26,122,191,0.12);
  --ice-light:  rgba(26,122,191,0.07);

  --gold:       #b87800;
  --gold-dim:   #9a6000;
  --gold-bg:    rgba(184,120,0,0.10);

  --green:      #12a050;
  --green-dim:  #0d8040;
  --green-bg:   rgba(18,160,80,0.10);

  --red:        #d01030;
  --red-dim:    #a80020;
  --red-bg:     rgba(208,16,48,0.10);

  --orange:     #d06000;
  --orange-bg:  rgba(208,96,0,0.10);

  --yellow:     #b07800;
  --yellow-bg:  rgba(176,120,0,0.10);

  --text:       #0c2840;
  --text-dim:   #3870a0;
  --text-muted: #80a8c8;

  --shadow:     0 1px 6px rgba(0,60,120,0.08), 0 4px 16px rgba(0,60,120,0.06);
  --shadow-lg:  0 4px 24px rgba(0,60,120,0.14);
}

/* ===== BASE ===== */
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 15px; line-height: 1.4; transition: background 0.3s, color 0.3s; }

/* Ice rink grid */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg,   rgba(96,200,240,0.04) 0, rgba(96,200,240,0.04) 1px, transparent 1px, transparent 52px),
    repeating-linear-gradient(90deg,  rgba(96,200,240,0.04) 0, rgba(96,200,240,0.04) 1px, transparent 1px, transparent 52px);
  transition: opacity 0.3s;
}
body.light-mode::before { opacity: 0.4; }

/* Top glow */
body::after {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 300px; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 100% at 50% -20%, rgba(60,160,255,0.14) 0%, transparent 70%);
}
body.light-mode::after { opacity: 0; }

/* ===== HEADER ===== */
header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #06111f 0%, #0d1e3a 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
body.light-mode header { background: linear-gradient(135deg, #0a3d6b 0%, #1565a8 100%); border-bottom-color: transparent; }

.header-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-bobby {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; border: 2px solid rgba(96,200,240,0.35);
  background: rgba(96,200,240,0.08); flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; }
.logo-title {
  font-family: var(--font-display); font-weight: 800; font-size: 16px;
  color: var(--ice); letter-spacing: 2.5px; line-height: 1;
  text-shadow: 0 0 20px rgba(96,200,240,0.4);
}
.logo-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); letter-spacing: 1.5px; margin-top: 1px; }

.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.clock { font-family: var(--font-mono); font-size: 18px; color: var(--ice); letter-spacing: 1px; white-space: nowrap; text-shadow: 0 0 12px rgba(96,200,240,0.3); }
.active-count-badge {
  display: flex; flex-direction: column; align-items: center;
  background: var(--green-bg); border: 1px solid var(--green-dim);
  border-radius: var(--radius); padding: 3px 10px;
}
.active-count-badge span:first-child { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--green); line-height: 1; text-shadow: 0 0 10px rgba(0,240,144,0.4); }
.active-count-badge span:last-child { font-size: 9px; color: var(--text-dim); letter-spacing: 2px; }

.header-controls { display: flex; align-items: center; gap: 8px; }
.btn-lock {
  font-family: var(--font-ui); font-weight: 600; font-size: 11px; letter-spacing: 1px;
  color: var(--text-dim); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-lock:hover { color: var(--red); border-color: var(--red-dim); }

/* Light mode toggle */
.btn-theme {
  font-size: 16px; background: none; border: none; cursor: pointer; padding: 4px 6px;
  border-radius: var(--radius); transition: background 0.2s;
  -webkit-tap-highlight-color: transparent; line-height: 1;
}
.btn-theme:hover { background: var(--ice-light); }

/* ===== TAB NAV ===== */
.tab-nav {
  background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 62px; z-index: 90;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--text-dim); background: none; border: none; cursor: pointer;
  padding: 13px 18px; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--ice); }
.tab-btn.active { color: var(--ice); border-bottom-color: var(--ice); text-shadow: 0 0 10px rgba(96,200,240,0.3); }

/* ===== LAYOUT ===== */
.tab-content { display: none; padding: 16px; max-width: 960px; margin: 0 auto; position: relative; z-index: 1; animation: fadeIn 0.18s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ===== CARDS ===== */
.search-section, .grid-section {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.section-title { font-family: var(--font-mono); font-size: 11px; color: var(--ice-dim); letter-spacing: 2.5px; }
.search-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: 2px; margin-bottom: 10px; }

/* ===== INPUTS ===== */
.search-row { display: flex; gap: 8px; }
.seal-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-mono); font-size: 16px;
  padding: 11px 14px; outline: none; min-width: 0;
  transition: border-color 0.2s, box-shadow 0.2s; -webkit-appearance: none;
}
.seal-input:focus { border-color: var(--ice-dim); box-shadow: 0 0 0 3px var(--ice-glow); }
.seal-input.small { flex: 0 0 120px; }
.seal-input::placeholder { color: var(--text-muted); }
.search-extras { display: flex; gap: 8px; margin-top: 8px; }
.extra-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-ui); font-size: 14px;
  padding: 9px 12px; outline: none; min-width: 0;
  transition: border-color 0.2s; -webkit-appearance: none;
}
.extra-input:focus { border-color: var(--border-hi); }
.extra-input::placeholder { color: var(--text-muted); }
.search-feedback { margin-top: 8px; min-height: 18px; font-family: var(--font-mono); font-size: 12px; }
.search-feedback.success { color: var(--green); }
.search-feedback.error   { color: var(--red); }
.search-feedback.info    { color: var(--ice-dim); }

/* ===== BUTTONS ===== */
.btn-activate {
  font-family: var(--font-ui); font-weight: 700; font-size: 13px; letter-spacing: 1.5px;
  color: #000; background: linear-gradient(135deg, var(--ice), var(--ice-dim));
  border: none; border-radius: var(--radius); padding: 11px 18px; cursor: pointer;
  white-space: nowrap; box-shadow: 0 0 16px rgba(96,200,240,0.25);
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-activate:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 0 24px rgba(96,200,240,0.4); }
.btn-activate:active { transform: none; }
.btn-activate:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-activate.btn-returning {
  background: linear-gradient(135deg, var(--green), var(--green-dim));
  box-shadow: 0 0 16px rgba(0,240,144,0.25); color: #000;
}

.btn-refresh {
  font-family: var(--font-ui); font-weight: 600; font-size: 12px; letter-spacing: 1px;
  color: var(--ice-dim); background: var(--ice-light); border: 1px solid var(--border-hi);
  border-radius: var(--radius); padding: 9px 14px; cursor: pointer;
  transition: background 0.2s, color 0.2s; -webkit-tap-highlight-color: transparent;
}
.btn-refresh:hover { color: var(--ice); background: rgba(96,200,240,0.14); }
.btn-refresh.small { padding: 6px 10px; font-size: 11px; }
.btn-refresh.spinning { animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-return {
  font-family: var(--font-ui); font-weight: 700; font-size: 12px; letter-spacing: 1px;
  color: #000; background: var(--green);
  border: none; border-radius: var(--radius); padding: 8px 14px; cursor: pointer;
  box-shadow: 0 0 10px rgba(0,240,144,0.2); white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s; -webkit-tap-highlight-color: transparent;
}
.btn-return:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-return:active { transform: none; }

.btn-extend {
  font-family: var(--font-ui); font-weight: 700; font-size: 12px; letter-spacing: 1px;
  color: #000; background: var(--gold);
  border: none; border-radius: var(--radius); padding: 8px 14px; cursor: pointer;
  box-shadow: 0 0 10px rgba(240,192,64,0.2); white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s; -webkit-tap-highlight-color: transparent;
}
.btn-extend:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-extend:active { transform: none; }

/* ===== LEGEND ===== */
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.legend-dot.available { background: var(--border-hi); }
.legend-dot.active-leg { background: var(--green); box-shadow: 0 0 5px rgba(0,240,144,0.5); }
.legend-dot.expired { background: var(--red); box-shadow: 0 0 5px rgba(255,51,85,0.5); }

/* ===== SEAL GRID ===== */
.seal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; }

.seal-tile {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, background 0.15s, box-shadow 0.2s;
  user-select: none; -webkit-tap-highlight-color: transparent; position: relative; overflow: hidden;
}
.seal-tile:active { transform: scale(0.92); }
.seal-tile.state-available:hover { border-color: var(--border-hi); background: var(--ice-light); }

.seal-tile.state-active {
  border-color: var(--green-dim); background: var(--green-bg);
  box-shadow: 0 0 8px rgba(0,240,144,0.12);
}
.seal-tile.state-warning { border-color: var(--gold-dim); background: var(--gold-bg); }
.seal-tile.state-expired {
  border-color: var(--red-dim); background: var(--red-bg);
  animation: expiredPulse 1.8s ease-in-out infinite;
}
@keyframes expiredPulse { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 14px rgba(255,51,85,0.35); } }
.seal-tile.highlighted {
  border-color: var(--ice) !important;
  box-shadow: 0 0 0 3px rgba(96,200,240,0.25), 0 0 16px rgba(96,200,240,0.2);
  transform: scale(1.06);
}

.tile-id { font-family: var(--font-mono); font-size: 17px; font-weight: bold; color: var(--text); line-height: 1; }
.tile-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); line-height: 1; }
.seal-tile.state-active .tile-id  { color: var(--green); text-shadow: 0 0 8px rgba(0,240,144,0.4); }
.seal-tile.state-expired .tile-id { color: var(--red); }
.seal-tile.state-warning .tile-id { color: var(--gold); }

/* ===== STATUS BAR ===== */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); padding: 0 2px; flex-wrap: wrap; gap: 6px;
}

/* ===== SKATEGUARD ===== */
.skateguard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.skateguard-list { display: flex; flex-direction: column; gap: 8px; }

.sg-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  box-shadow: var(--shadow); animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.sg-row.sg-ok      { border-left-color: var(--green); }
.sg-row.sg-warn    { border-left-color: var(--gold);  background: rgba(240,192,64,0.05); }
.sg-row.sg-expired { border-left-color: var(--red);   background: var(--red-bg); animation: expiredPulse 1.8s ease-in-out infinite, slideIn 0.2s ease; }

.sg-id { font-family: var(--font-mono); font-size: 26px; font-weight: bold; min-width: 46px; text-align: center; flex-shrink: 0; }
.sg-row.sg-ok .sg-id      { color: var(--green); text-shadow: 0 0 10px rgba(0,240,144,0.3); }
.sg-row.sg-warn .sg-id    { color: var(--gold); }
.sg-row.sg-expired .sg-id { color: var(--red); }

.sg-info-group { display: flex; flex-wrap: wrap; gap: 12px; flex: 1; min-width: 0; }
.sg-info { min-width: 0; }
.sg-label { font-size: 9px; color: var(--text-muted); letter-spacing: 1.5px; margin-bottom: 2px; }
.sg-value { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.sg-notes .sg-value { font-size: 12px; color: var(--text-dim); }

.sg-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.sg-time-remaining { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; white-space: nowrap; }
.sg-row.sg-ok .sg-time-remaining      { color: var(--green); text-shadow: 0 0 12px rgba(0,240,144,0.3); }
.sg-row.sg-warn .sg-time-remaining    { color: var(--gold); }
.sg-row.sg-expired .sg-time-remaining { color: var(--red); text-shadow: 0 0 12px rgba(255,51,85,0.4); }
.sg-actions { display: flex; gap: 6px; }

.sg-empty { text-align: center; padding: 50px 20px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ===== PARTY ===== */
.party-note { font-family: var(--font-mono); font-size: 11px; color: var(--gold); letter-spacing: 1px; }
.party-list { display: flex; flex-direction: column; gap: 8px; }
.party-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-lg); padding: 12px 16px;
  box-shadow: var(--shadow);
}
.party-id { font-family: var(--font-mono); font-size: 22px; font-weight: bold; color: var(--gold); flex-shrink: 0; min-width: 44px; text-shadow: 0 0 8px rgba(240,192,64,0.3); }
.party-room-badge {
  background: var(--gold-bg); border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 4px 10px;
  font-family: var(--font-mono); font-size: 13px; color: var(--gold); flex-shrink: 0;
}
.party-empty { text-align: center; padding: 30px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }

/* ===== LOCK SCREEN ===== */
.lock-screen { display: flex; align-items: center; justify-content: center; min-height: 320px; padding: 20px; }
.lock-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px 28px;
  text-align: center; max-width: 340px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.lock-icon { font-size: 36px; margin-bottom: 12px; }
.lock-title { font-family: var(--font-mono); font-size: 12px; letter-spacing: 2px; color: var(--ice); margin-bottom: 8px; }
.lock-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 18px; line-height: 1.5; }
.lock-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-mono); font-size: 16px;
  padding: 12px; margin-bottom: 6px; outline: none; text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s; -webkit-appearance: none;
}
.lock-input:focus { border-color: var(--ice-dim); box-shadow: 0 0 0 3px var(--ice-glow); }
.lock-error { font-family: var(--font-mono); font-size: 12px; color: var(--red); min-height: 18px; margin-bottom: 10px; }
.lock-submit { width: 100%; padding: 13px; font-size: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(4,10,24,0.75); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel2); border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(96,200,240,0.08);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-8px); } to { opacity: 1; transform: none; } }
.modal-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--ice-dim); margin-bottom: 14px; }
.modal-body { margin-bottom: 18px; }
.modal-seal-id { font-family: var(--font-display); font-weight: 800; font-size: 52px; color: var(--ice); line-height: 1; margin-bottom: 10px; text-shadow: 0 0 20px rgba(96,200,240,0.3); }
.modal-meta { font-family: var(--font-ui); font-size: 14px; color: var(--text-dim); line-height: 1.9; }
.modal-meta strong { color: var(--text); }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions button { flex: 1; min-width: 90px; }
.btn-modal-cancel {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; letter-spacing: 1px;
  color: var(--text-dim); background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 14px; cursor: pointer; flex: 0 0 auto !important;
  transition: color 0.2s, border-color 0.2s; -webkit-tap-highlight-color: transparent;
}
.btn-modal-cancel:hover { color: var(--text); border-color: var(--border-hi); }
.modal-extend-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-mono); font-size: 16px;
  padding: 10px 14px; margin-top: 14px; outline: none;
  transition: border-color 0.2s; -webkit-appearance: none;
}
.modal-extend-input:focus { border-color: var(--ice-dim); }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 20px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  font-family: var(--font-ui); font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: var(--radius);
  border: 1px solid; animation: toastIn 0.25s ease; pointer-events: auto;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast.success { background: var(--green-bg);  border-color: var(--green-dim); color: var(--green); }
.toast.error   { background: var(--red-bg);    border-color: var(--red-dim);   color: var(--red); }
.toast.info    { background: var(--ice-light);  border-color: var(--border-hi); color: var(--ice); }
.toast.fadeOut { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  .header-inner { padding: 8px 12px; }
  .logo-bobby { width: 34px; height: 34px; }
  .logo-title { font-size: 14px; letter-spacing: 1.5px; }
  .clock { font-size: 15px; }
  .active-count-badge span:first-child { font-size: 17px; }
  .tab-btn { padding: 11px 12px; font-size: 11px; }
  .tab-content { padding: 12px 10px; }
  .search-section, .grid-section { padding: 12px; border-radius: var(--radius); }
  .search-row { flex-direction: column; }
  .btn-activate { width: 100%; padding: 13px; font-size: 14px; }
  .search-extras { flex-direction: column; }
  .seal-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
  .tile-id { font-size: 15px; }
  .sg-row { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .sg-id { font-size: 28px; min-width: auto; }
  .sg-info-group { width: 100%; order: 2; }
  .sg-right { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; order: 3; }
  .sg-time-remaining { font-size: 24px; }
  .party-row { gap: 8px; }
  .party-id { font-size: 20px; }
  .modal { padding: 20px 16px; }
  .modal-seal-id { font-size: 40px; }
  .modal-actions { flex-direction: column; }
  .btn-modal-cancel { flex: 1 !important; }
  .toast-container { bottom: 16px; right: 10px; left: 10px; }
}
@media (max-width: 360px) {
  .seal-grid { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
  .logo-sub { display: none; }
}

/* ============================================================
   NEW: Party seal grid style (orange instead of blue)
   ============================================================ */
.seal-tile.party-type {
  background: rgba(255,140,0,0.10);
  border-color: rgba(255,140,0,0.5);
}
.seal-tile.party-type.state-available .tile-id { color: var(--orange); }
.seal-tile.party-type.state-available:hover { background: rgba(255,140,0,0.18); border-color: var(--orange); }

.seal-tile.state-party-active {
  border-color: var(--orange); background: rgba(255,140,0,0.18);
  box-shadow: 0 0 12px rgba(255,140,0,0.3);
}
.seal-tile.state-party-active .tile-id { color: var(--orange); text-shadow: 0 0 8px rgba(255,140,0,0.4); }

/* Legend party dot */
.legend-dot.party { background: var(--orange); box-shadow: 0 0 5px rgba(255,140,0,0.5); }

/* ============================================================
   NEW: Skateguard row party tag + party variant
   ============================================================ */
.sg-id { position: relative; }
.sg-party-tag {
  font-family: var(--font-mono); font-size: 8px; letter-spacing: 1px;
  color: var(--orange); margin-top: 2px;
  text-shadow: 0 0 6px rgba(255,140,0,0.4);
}
.sg-row.sg-party { border-left-color: var(--orange); }
.sg-row.sg-party .sg-id { color: var(--orange); text-shadow: 0 0 8px rgba(255,140,0,0.3); }
.sg-row.sg-party .sg-time-remaining { color: var(--orange); }

/* ============================================================
   NEW: History tab
   ============================================================ */
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.history-controls { display: flex; gap: 8px; align-items: center; }
.history-controls .extra-input { width: 180px; flex: 0 0 auto; }
.history-list { display: flex; flex-direction: column; gap: 5px; }

.history-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  transition: background 0.2s;
}
.history-row.h-rent    { border-left-color: var(--green); }
.history-row.h-return  { border-left-color: var(--ice-dim); }
.history-row.h-extend  { border-left-color: var(--gold); }
.history-row.h-reduce  { border-left-color: var(--red); }
.history-row.h-party   { border-left-color: var(--orange); }

.h-icon {
  font-size: 18px; width: 28px; text-align: center;
  flex-shrink: 0; color: var(--text-dim);
}
.h-rent .h-icon    { color: var(--green); }
.h-return .h-icon  { color: var(--ice); }
.h-extend .h-icon  { color: var(--gold); }
.h-reduce .h-icon  { color: var(--red); }
.h-party .h-icon   { color: var(--orange); }

.h-main { flex: 1; min-width: 0; }
.h-line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.h-seal { font-family: var(--font-mono); font-size: 16px; font-weight: bold; color: var(--text); }
.h-label { font-size: 13px; color: var(--text-dim); }
.h-notes { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.h-time { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
.history-empty { text-align: center; padding: 40px; color: var(--text-muted); font-family: var(--font-mono); font-size: 13px; }

/* ============================================================
   NEW: Chat tab
   ============================================================ */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
}
.chat-name-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.chat-name-label strong { color: var(--ice); }
.chat-name-change {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 10px; text-decoration: underline; padding: 0 4px;
}
.chat-name-change:hover { color: var(--ice); }

.chat-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.chat-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}
.chat-status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.chat-status-dot.offline { background: var(--red); }

#chatUI { display: flex !important; flex-direction: column; height: calc(100vh - 220px); min-height: 400px; }

.chat-messages {
  flex: 1; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 10px;
}
.chat-empty { text-align: center; padding: 40px; color: var(--text-muted); font-family: var(--font-mono); }

.chat-msg {
  max-width: 75%; padding: 8px 12px;
  border-radius: var(--radius); font-size: 14px;
  word-wrap: break-word;
}
.chat-msg-other {
  align-self: flex-start;
  background: var(--bg2); border: 1px solid var(--border);
}
.chat-msg-own {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--ice-dim), var(--ice));
  color: #000;
}
.chat-msg-own.chat-msg-staff {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
}
.chat-msg-other.chat-msg-staff {
  border-color: var(--gold-dim);
  background: var(--gold-bg);
}
.chat-msg-head {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  margin-bottom: 3px;
}
.chat-msg-name { font-size: 11px; font-weight: 600; opacity: 0.85; }
.chat-msg-own .chat-msg-name { color: rgba(0,0,0,0.7); }
.chat-msg-time { font-size: 10px; opacity: 0.6; font-family: var(--font-mono); }
.chat-msg-text { line-height: 1.4; }
.chat-staff-tag {
  display: inline-block; font-size: 8px; padding: 1px 4px;
  background: var(--gold); color: #000; border-radius: 3px;
  letter-spacing: 1px; margin-left: 3px;
}
.chat-msg-own .chat-staff-tag { background: rgba(0,0,0,0.4); color: #fff; }

.chat-input-row { display: flex; gap: 8px; }
.chat-input-row .seal-input { flex: 1; font-family: var(--font-ui); font-size: 14px; }

/* Chat badge on tab */
.chat-badge {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 10px; font-weight: bold; padding: 2px 6px;
  border-radius: 10px; margin-left: 4px; min-width: 18px; text-align: center;
  box-shadow: 0 0 8px rgba(255,51,85,0.5);
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================================
   NEW: Modal extension log
   ============================================================ */
.modal-ext-log {
  margin-top: 14px; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.modal-ext-title {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); letter-spacing: 1.5px; margin-bottom: 6px;
}
.modal-ext-row {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-dim); padding: 3px 0;
}
.modal-ext-row .pos { color: var(--green); font-weight: bold; }
.modal-ext-row .neg { color: var(--red); font-weight: bold; }

/* ============================================================
   MOBILE adjustments for new tabs
   ============================================================ */
@media (max-width: 480px) {
  .history-controls { width: 100%; flex-direction: column; gap: 6px; }
  .history-controls .extra-input { width: 100%; }
  .history-row { padding: 8px 12px; gap: 8px; }
  .h-icon { font-size: 16px; width: 22px; }

  #chatUI { height: calc(100vh - 240px); min-height: 320px; }
  .chat-header { padding: 10px 12px; }
  .chat-msg { max-width: 85%; font-size: 13px; }

  /* Bigger chat input + smaller send button on mobile */
  .chat-input-row { gap: 6px; }
  .chat-input-row .seal-input {
    font-size: 16px; padding: 14px 14px;
  }
  .chat-input-row .btn-activate {
    padding: 10px 14px; font-size: 12px;
    letter-spacing: 1px; flex: 0 0 auto;
    width: auto; min-width: 0;
  }

  .chat-badge { font-size: 9px; padding: 1px 5px; }
}

/* ============================================================
   NEW: History rental records (replaces simple event log)
   ============================================================ */
.history-record {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-lg); padding: 14px 16px;
  margin-bottom: 8px; transition: background 0.2s;
}
.history-record.h-returned { border-left-color: var(--ice-dim); opacity: 0.85; }
.history-record.h-active   { border-left-color: var(--green); }
.history-record.h-party-rec { border-left-color: var(--orange); }

.hr-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.hr-id {
  font-family: var(--font-mono); font-size: 22px; font-weight: bold;
  color: var(--text); display: flex; align-items: center; gap: 8px;
}
.h-party-rec .hr-id { color: var(--orange); }
.hr-party-tag {
  font-size: 9px; padding: 2px 6px; background: var(--orange-bg);
  color: var(--orange); border: 1px solid var(--orange);
  border-radius: 4px; letter-spacing: 1px;
}
.hr-status {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  padding: 3px 8px; border-radius: 4px;
}
.h-active .hr-status   { color: var(--green); background: var(--green-bg); border: 1px solid var(--green); }
.h-returned .hr-status { color: var(--ice-dim); background: var(--ice-light); border: 1px solid var(--ice-dim); }
.h-party-rec .hr-status { color: var(--orange); background: var(--orange-bg); border: 1px solid var(--orange); }

.hr-times {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px; margin-bottom: 8px;
}
.hr-time-block { background: var(--bg2); border-radius: var(--radius); padding: 8px 12px; }
.hr-time-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 3px; }
.hr-time-val { font-family: var(--font-mono); font-size: 14px; color: var(--text); }

.hr-extensions {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.hr-ext-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-muted); }
.hr-ext-chip {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 8px;
  border-radius: 4px; border: 1px solid;
}
.hr-ext-chip.pos { background: var(--green-bg); border-color: var(--green-dim); color: var(--green); }
.hr-ext-chip.neg { background: var(--red-bg); border-color: var(--red-dim); color: var(--red); }
.hr-ext-total { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-left: auto; font-weight: bold; }

.hr-notes {
  margin-top: 8px; padding: 6px 10px;
  background: var(--bg2); border-left: 2px solid var(--ice-dim);
  font-size: 12px; color: var(--text-dim); border-radius: 4px;
}

@media (max-width: 480px) {
  .history-record { padding: 12px; }
  .hr-id { font-size: 18px; }
  .hr-times { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .hr-time-block { padding: 6px 8px; }
  .hr-time-val { font-size: 13px; }
}

/* ============================================================
   Multi-arena: clickable logo to switch arenas
   ============================================================ */
.logo-link {
  display: inline-flex; text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}
.logo-link:hover { opacity: 0.85; transform: scale(1.05); }
