/* ========================================
   SPIRALBOUND — Core Stylesheet
   ======================================== */

:root {
  --bg: #0f0f12;
  --bg-surface: #151518;
  --bg-card: #1b1b1f;
  --bg-input: #121215;
  --bg-deep: #09090c;
  --text: #ccc8c0;
  --text-dim: #68605a;
  --text-bright: #ede8e0;
  --storm: #9c7cf2;
  --fire: #f06040;
  --ice: #4fc3f7;
  --life: #66bb6a;
  --death: #8a8a9a;
  --myth: #e8b830;
  --balance: #d4b896;
  --gold: #e8c840;
  --gold-dim: #a08828;
  --crit: #e8c840;
  --fizzle: #e05040;
  --heal: #5aaa58;
  --cast: #9c7cf2;
  --border: #252528;
  --border-light: #35353a;
  --pip: #d8d4cc;
  --powerpip: #e8c840;
  --hp-bar: #d04838;
  --mana-bar: #4098d0;
  --xp-bar: #50b050;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- HEADER ---- */
.game-header {
  background: linear-gradient(180deg, #1c1c20 0%, var(--bg-surface) 100%);
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--border) 0%, var(--gold-dim) 20%, var(--gold) 50%, var(--gold-dim) 80%, var(--border) 100%) 1;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.6), 0 4px 24px rgba(0,0,0,0.3), inset 0 -1px 0 rgba(255,255,255,0.03);
}

.game-title {
  font-size: 18px;
  color: var(--text-bright);
  letter-spacing: 4px;
  text-transform: uppercase;
  font-weight: normal;
}

.game-title span {
  color: var(--cast);
  text-shadow: 0 0 12px color-mix(in srgb, var(--cast) 30%, transparent);
}

.header-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
}

.header-stats .stat-val {
  color: var(--gold);
}

/* ---- RESOURCE BARS ---- */
.resource-panel {
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg) 100%);
  padding: 8px 16px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, var(--border) 0%, color-mix(in srgb, var(--cast) 40%, var(--border)) 50%, var(--border) 100%) 1;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.resource-bar {
  flex: 1;
  min-width: 120px;
}

.resource-bar .bar-label {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.resource-bar .bar-track {
  height: 8px;
  background: var(--bg-deep);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}

.resource-bar .bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 60%);
  background-blend-mode: overlay;
}

.bar-fill.hp { background: var(--hp-bar); }
.bar-fill.mana { background: var(--mana-bar); }
.bar-fill.xp { background: var(--xp-bar); }

.pip-display {
  display: flex;
  gap: 3px;
  align-items: center;
  min-width: 100px;
}

.pip-display .pip-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 4px;
}

.pip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-deep);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.pip-dot.regular { background: var(--pip); box-shadow: 0 0 4px rgba(200,192,176,0.4), inset 0 1px 0 rgba(255,255,255,0.2); }
.pip-dot.power { background: var(--powerpip); box-shadow: 0 0 6px rgba(232,200,64,0.5), inset 0 1px 0 rgba(255,255,255,0.25); }
.pip-dot.empty { background: var(--bg-deep); }

/* ---- LAYOUT ---- */
.game-layout {
  display: flex;
  height: calc(100vh - 74px);
  overflow: hidden;
}

.log-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(0,0,0,0.4);
}

.log-sidebar-header {
  padding: 8px 10px;
  background: linear-gradient(180deg, #18181c 0%, var(--bg-deep) 100%);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid transparent;
  border-image: linear-gradient(90deg, var(--border), var(--gold-dim), var(--border)) 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-sidebar .combat-log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.5;
  font-family: 'Courier New', monospace;
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- TAB BAR ---- */
.tab-bar {
  display: flex;
  background: var(--bg-deep);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, var(--border), color-mix(in srgb, var(--cast) 30%, var(--border)) 50%, var(--border)) 1;
  overflow-x: auto;
  gap: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.tab-btn {
  flex: 0 0 auto;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: Georgia, serif;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.tab-btn:hover { color: var(--text-bright); }
.tab-btn.active {
  color: var(--cast);
  border-bottom-color: var(--cast);
  text-shadow: 0 0 10px color-mix(in srgb, var(--cast) 25%, transparent);
}

/* ---- TAB CONTENT ---- */
.tab-content {
  display: none;
  padding: 12px 16px;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active { display: block; }

/* ---- HUB TAB ---- */
.status-box {
  background: linear-gradient(180deg, var(--bg-card) 0%, color-mix(in srgb, var(--bg-card) 70%, var(--bg)) 100%);
  border: 1px solid var(--border);
  border-top: 1px solid color-mix(in srgb, var(--cast) 25%, var(--border));
  border-radius: 2px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02), inset 0 1px 0 rgba(255,255,255,0.04);
}

details.status-box {
  border: none;
  background: none;
  box-shadow: none;
  padding: 0;
}

.status-line {
  font-size: 13px;
  color: var(--cast);
  margin-bottom: 4px;
}

.status-detail {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.event-banner {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--gold-dim);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 12px rgba(232,200,64,0.04);
}

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

.event-banner .event-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--gold);
}

.event-banner .event-desc {
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
}

.event-banner .event-detail {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.event-banner .event-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-banner .event-actions button {
  background: linear-gradient(180deg, #f0d860 0%, #c8a020 100%);
  color: var(--bg-deep);
  border: 1px solid var(--gold-dim);
  padding: 6px 16px;
  border-radius: 2px;
  font-family: Georgia, serif;
  font-size: 11px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.event-banner .event-actions button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.event-banner .event-actions button.choice-b {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-light);
}

.event-banner .event-timer {
  font-size: 10px;
  color: var(--fizzle);
}

/* ---- COMBAT LOG ---- */
.combat-log {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  height: 300px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
}

.combat-log .log-entry {
  padding: 1px 0;
}

.log-entry.cast { color: var(--cast); }
.log-entry.fizzle { color: var(--fizzle); }
.log-entry.crit { color: var(--crit); }
.log-entry.heal { color: var(--heal); }
.log-entry.info { color: #9a9490; }
.log-entry.kill { color: var(--text-bright); }
.log-entry.death { color: var(--fizzle); font-weight: normal; }
.log-entry.system { color: var(--text-bright); }

.combat-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.combat-controls button, .btn {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  color: var(--text);
  border: 1px solid var(--border-light);
  padding: 6px 14px;
  border-radius: 2px;
  font-family: Georgia, serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}

.btn:hover, .combat-controls button:hover {
  background: linear-gradient(180deg, var(--border-light) 0%, var(--bg-card) 100%);
  color: var(--text-bright);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}

.btn.active {
  background: linear-gradient(180deg, #f0d860 0%, #c8a020 100%);
  color: var(--bg-deep);
  border-color: var(--gold-dim);
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}

.btn.primary {
  background: linear-gradient(180deg, #f0d860 0%, #c8a020 100%);
  color: var(--bg-deep);
  border-color: var(--gold-dim);
  font-weight: normal;
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ---- ENEMY DISPLAY ---- */
.enemy-panel {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.enemy-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 2px solid var(--border);
  border-radius: 2px;
  padding: 0;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  overflow: hidden;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02);
}

.enemy-card .enemy-header {
  padding: 7px 10px 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.enemy-card .enemy-name {
  font-size: 12px;
  color: var(--text-bright);
  font-weight: bold;
}

.enemy-card .enemy-school-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.enemy-card .enemy-body {
  padding: 0 10px 6px;
}

.enemy-card .enemy-statuses {
  font-size: 9px;
  color: var(--text-dim);
  padding: 0 10px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.enemy-card .enemy-statuses .status-tag {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.enemy-card .enemy-hp-section {
  padding: 4px 10px 8px;
}

.enemy-card .bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.enemy-card .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.enemy-card .enemy-hp-text {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
}

.enemy-card.targeted {
  border-color: var(--cast);
  box-shadow: 0 0 14px color-mix(in srgb, var(--cast) 25%, transparent), 0 0 4px color-mix(in srgb, var(--cast) 15%, transparent), inset 0 0 20px rgba(255, 255, 255, 0.02);
  background: linear-gradient(180deg, color-mix(in srgb, var(--cast) 4%, var(--bg-card)) 0%, var(--bg) 100%);
}

.enemy-card.defeated {
  opacity: 0.2;
  transform: scale(0.92);
  filter: brightness(0.6);
  border-color: var(--border) !important;
  box-shadow: none !important;
}

.enemy-card.defeated .enemy-header {
  opacity: 0.6;
}

.enemy-card.boss-card {
  border-width: 2px;
  border-style: solid;
  border-image: linear-gradient(135deg, var(--gold), var(--gold-dim), var(--gold), var(--gold-dim), var(--gold)) 1;
  border-radius: 0;
  max-width: 320px;
  box-shadow: 0 0 16px rgba(232,200,64,0.08), 0 2px 8px rgba(0,0,0,0.5);
}

.enemy-card.boss-card .enemy-header {
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 8%, var(--bg-card)) 0%, var(--bg-card) 100%) !important;
}

.enemy-card.boss-card .enemy-name {
  color: var(--gold);
  font-size: 13px;
}

/* ---- MANUAL COMBAT HAND ---- */
.spell-hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 2px;
  align-items: flex-end;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.6);
}

.spell-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  border: 2px solid var(--border-light);
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  overflow: hidden;
  position: relative;
  flex: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.02);
}

.spell-card:hover {
  transform: translateY(-4px);
  border-color: var(--cast);
  box-shadow: 0 6px 20px rgba(0,0,0,0.7), 0 0 10px color-mix(in srgb, var(--cast) 20%, transparent);
}
.spell-card.disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.spell-card.disabled:hover { transform: none; box-shadow: none; }

.spell-card .spell-pip {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 1;
  border: 1px solid rgba(255,255,255,0.2);
}

.spell-card .spell-acc {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 8px;
  z-index: 1;
  opacity: 0.7;
}

.spell-card .spell-art {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.spell-card .spell-art .spell-type-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: bold;
}

.spell-card .spell-name-bar {
  padding: 4px 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-card);
}

.spell-card .spell-name {
  font-size: 10px;
  font-weight: bold;
  line-height: 1.2;
  color: var(--text-bright);
}

.spell-card .spell-effect {
  padding: 5px 6px;
  font-size: 11px;
  font-weight: bold;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-card .spell-tc-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 0.5px;
  z-index: 2;
}

.spell-card .spell-discard {
  display: block;
  width: 100%;
  padding: 3px 0;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.6;
}

.spell-card:hover .spell-discard {
  opacity: 1;
  color: var(--fizzle);
}

.spell-card .spell-discard:hover {
  background: rgba(239, 83, 80, 0.15);
}

/* ---- FISHING TIMING BAR ---- */
@keyframes sweep-bar { 0% { left: 0%; } 50% { left: 96%; } 100% { left: 0%; } }
.fishing-bar {
  position: relative;
  height: 38px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  border: 2px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}
.fishing-bar .catch-zone {
  position: absolute;
  height: 100%;
  background: linear-gradient(180deg, rgba(102,187,106,0.25) 0%, rgba(102,187,106,0.1) 100%);
  border-left: 2px solid var(--heal);
  border-right: 2px solid var(--heal);
}
.fishing-bar .catch-label {
  position: absolute;
  top: 50%;
  transform: translate(-50%,-50%);
  font-size: 9px;
  color: var(--heal);
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
  font-weight: bold;
  opacity: 0.8;
}
.fishing-bar .sweep-indicator {
  position: absolute;
  top: 3px;
  width: 6px;
  height: calc(100% - 6px);
  background: var(--text-bright);
  border-radius: 3px;
  box-shadow: 0 0 10px var(--text-bright), 0 0 20px rgba(255,255,255,0.2);
}
.bar-track {
  height: 6px;
  background: var(--bg-deep);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.7);
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}

.bar-track.thick { height: 8px; border-radius: 4px; }
.bar-track.thick .bar-fill { border-radius: 4px; }

/* ---- DECK / PRIORITY RULES ---- */
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-row {
  display: flex;
  gap: 6px;
  align-items: center;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
}

.rule-row .rule-num {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 20px;
}

.rule-row select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 11px;
  flex: 1;
  min-width: 0;
}

.rule-row .rule-label {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.rule-row .rule-delete {
  background: none;
  border: none;
  color: var(--fizzle);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}

/* ---- MAP ---- */
.world-map {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zone-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.zone-row.completed {
  border-color: var(--cast);
  opacity: 0.7;
}

.zone-row.current {
  border-color: var(--cast);
  background: linear-gradient(180deg, color-mix(in srgb, var(--cast) 4%, var(--bg-card)) 0%, var(--bg) 100%);
  box-shadow: 0 0 8px color-mix(in srgb, var(--cast) 15%, transparent);
}

.zone-row.locked {
  opacity: 0.4;
}

.zone-row .zone-name {
  flex: 1;
  color: var(--text);
}

.zone-row .zone-progress {
  color: var(--text-dim);
  font-size: 11px;
}

.zone-row .zone-icon {
  font-size: 14px;
}

/* ---- SECTION HEADERS ---- */
.section-head {
  font-size: 13px;
  color: var(--text-bright);
  letter-spacing: 1px;
  font-weight: normal;
  margin: 0;
  padding: 0;
}
div.section-head {
  padding: 6px 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--cast) 40%, var(--border));
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--cast) 15%, var(--border-light)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--cast) 25%, #454548); }

/* ---- SPIRAL THEME (Balance endgame) ---- */
body.spiral-theme {
  --cast: var(--balance);
  --spiral-grad: linear-gradient(90deg, var(--storm), var(--fire), var(--myth), var(--life), var(--ice), var(--death));
}
body.spiral-theme .game-title { letter-spacing: 3px; }
body.spiral-theme .game-title span { color: var(--balance); }
body.spiral-theme .game-header { border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, transparent 10%, var(--storm), var(--fire), var(--myth), var(--life), var(--ice), var(--death), transparent 90%) 1; }
body.spiral-theme .tab-btn.active { border-image: var(--spiral-grad) 1; }
body.spiral-theme .section-head { border-image: var(--spiral-grad) 1; }
body.spiral-theme .log-sidebar { border-right-color: transparent; border-image: linear-gradient(180deg, var(--storm), var(--fire), var(--ice), var(--life), var(--death), var(--myth)) 1; border-right-width: 2px; border-right-style: solid; }
body.spiral-theme .btn.active, body.spiral-theme .btn.primary { background: var(--spiral-grad); -webkit-background-clip: text; background-clip: text; color: transparent; border-image: var(--spiral-grad) 1; }
body.spiral-theme .enemy-card.targeted { border-image: var(--spiral-grad) 1; box-shadow: 0 0 8px rgba(255,255,255,0.15); }
body.spiral-theme .bar-fill.xp { background: linear-gradient(90deg, var(--storm), var(--fire), var(--myth), var(--life)); }
body.spiral-theme .bar-fill.hp { background: linear-gradient(90deg, var(--fire), var(--myth), var(--life)); }
body.spiral-theme .bar-fill.mana { background: linear-gradient(90deg, var(--storm), var(--ice), var(--death)); }
body.spiral-theme details > summary { border-bottom: 1px solid transparent; border-image: var(--spiral-grad) 1; }
body.spiral-theme .spell-card:hover { box-shadow: 0 6px 16px rgba(255,255,255,0.15), 0 0 8px rgba(212,184,150,0.2); }
body.spiral-theme .pip-dot.power { background: linear-gradient(135deg, var(--storm), var(--fire), var(--myth)); }
body.spiral-theme .achievement-toast { border-image: var(--spiral-grad) 1; border-left: none; }
body.spiral-theme .bazaar-tab.active { background: var(--spiral-grad) !important; -webkit-background-clip: text !important; background-clip: text !important; color: transparent !important; border-image: var(--spiral-grad) 1 !important; }
body.spiral-theme .event-banner { border-image: var(--spiral-grad) 1; border-left: none; }
body.spiral-theme .fishing-bar { border-image: var(--spiral-grad) 1; }
body.spiral-theme .fishing-bar .catch-zone { border-left-color: var(--balance); border-right-color: var(--balance); background: linear-gradient(180deg, rgba(212,184,150,0.2) 0%, rgba(212,184,150,0.05) 100%); }
body.spiral-theme .resource-panel { border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, transparent 15%, var(--storm), var(--fire), var(--myth), var(--life), var(--ice), transparent 85%) 1; }

/* ---- SCHOOL THEMES ---- */
body.school-storm {
  --cast: var(--storm);
}
body.school-storm .game-title span { color: var(--storm); }

body.school-fire {
  --cast: var(--fire);
}
body.school-fire .game-title span { color: var(--fire); }

body.school-ice {
  --cast: var(--ice);
}
body.school-ice .game-title span { color: var(--ice); }

body.school-life {
  --cast: var(--life);
}
body.school-life .game-title span { color: var(--life); }

body.school-death {
  --cast: var(--death);
}
body.school-death .game-title span { color: var(--death); }

body.school-myth {
  --cast: var(--myth);
}
body.school-myth .game-title span { color: var(--myth); }

/* ---- BAZAAR ---- */
.bazaar-tab { font-size: 11px !important; padding: 4px 12px !important; }
.bazaar-tab.active { background: var(--cast) !important; color: var(--bg) !important; border-color: var(--cast) !important; }
.bazaar-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; margin-bottom: 4px; background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.bazaar-row:hover { border-color: var(--border-light); }
.bazaar-row .item-info { flex: 1; }
.bazaar-row .item-name { color: var(--text-bright); }
.bazaar-row .item-meta { color: var(--text-dim); font-size: 11px; }
.bazaar-row .item-actions { display: flex; gap: 4px; align-items: center; }
.bazaar-row .price-tag { font-size: 11px; padding: 2px 6px; border-radius: 3px; }
.bazaar-row .price-up { color: var(--fizzle); }
.bazaar-row .price-down { color: var(--heal); }
.bazaar-row .price-normal { color: var(--gold); }
.bazaar-row .stock-tag { color: var(--text-dim); font-size: 10px; margin-left: 4px; }
.bazaar-section-head { font-size: 12px; color: var(--cast); margin: 10px 0 6px 0; padding-bottom: 3px; border-bottom: 1px solid var(--border); }

/* ---- COMBAT FEEDBACK ---- */
@keyframes damage-flash { 0% { background: var(--fizzle); } 100% { background: var(--bg-card); } }
@keyframes crit-flash { 0% { box-shadow: 0 0 12px var(--crit); } 100% { box-shadow: none; } }
@keyframes heal-flash { 0% { background: var(--heal); } 100% { background: var(--bg-card); } }
@keyframes save-slide { 0% { transform: translateY(20px); opacity: 0; } 15% { transform: translateY(0); opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.save-toast { position: fixed; bottom: 12px; right: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 2px; padding: 4px 10px; font-size: 10px; color: var(--text-dim); pointer-events: none; opacity: 0; z-index: 50; animation: save-slide 1.5s ease-out; font-family: Georgia, serif; }

/* Achievement toast */
@keyframes ach-slide { 0% { transform: translateX(100%); opacity: 0; } 10% { transform: translateX(0); opacity: 1; } 85% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(100%); opacity: 0; } }
.achievement-toast {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border: 1px solid var(--gold-dim); border-left: 3px solid var(--gold);
  border-radius: 2px; padding: 12px 16px; min-width: 240px; max-width: 320px;
  pointer-events: none;
  animation: ach-slide 3.5s ease-in-out forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7), 0 0 16px rgba(232,200,64,0.06);
  font-family: Georgia, serif;
}
.achievement-toast .ach-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--gold); margin-bottom: 4px;
}
.achievement-toast .ach-name {
  font-size: 14px; color: var(--text-bright); font-weight: bold; margin-bottom: 2px;
}
.achievement-toast .ach-desc {
  font-size: 11px; color: var(--text-dim); line-height: 1.4;
}
.enemy-card.hit { animation: damage-flash 0.4s ease-out; }
.enemy-card.crit-hit { animation: crit-flash 0.6s ease-out; border-color: var(--crit) !important; }
.enemy-card.healed { animation: heal-flash 0.4s ease-out; }

/* Floating damage/heal numbers */
@keyframes float-up { 0% { opacity: 1; transform: translateY(0) scale(1); } 50% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px) scale(0.8); } }
.float-number {
  position: fixed;
  font-weight: bold;
  font-size: 14px;
  pointer-events: none;
  z-index: 100;
  animation: float-up 1s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  transform: translateX(-50%);
}
.float-number.damage { color: var(--fizzle); }
.float-number.heal { color: var(--heal); }
.float-number.crit { color: var(--gold); font-size: 18px; text-shadow: 0 0 8px rgba(255,215,0,0.5), 0 1px 4px rgba(0,0,0,0.9); }

/* Level up flash */
@keyframes levelup-pulse { 0% { box-shadow: 0 0 0 0 rgba(255,215,0,0.7); } 40% { box-shadow: 0 0 30px 6px rgba(255,215,0,0.4); } 100% { box-shadow: none; } }
.levelup-flash { animation: levelup-pulse 1s ease-out; }

/* Pip gain bounce */
@keyframes pip-bounce { 0% { transform: scale(1.5); } 50% { transform: scale(0.9); } 100% { transform: scale(1); } }
.pip-new { animation: pip-bounce 0.3s ease-out; }

/* Screen shake for big hits */
@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-3px) translateY(1px); }
  30% { transform: translateX(3px) translateY(-1px); }
  50% { transform: translateX(-2px); }
  70% { transform: translateX(2px) translateY(1px); }
  90% { transform: translateX(-1px); }
}
.shaking { animation: screen-shake 0.35s ease-out; }

/* Enemy death animation */
@keyframes enemy-die {
  0% { opacity: 1; transform: scale(1); filter: brightness(1); }
  30% { opacity: 0.8; transform: scale(1.02); filter: brightness(1.5); }
  100% { opacity: 0.2; transform: scale(0.92); filter: brightness(0.6); }
}
.enemy-card.dying { animation: enemy-die 0.6s ease-out forwards; pointer-events: none; }

/* Crit screen flash */
@keyframes crit-screen-flash {
  0% { opacity: 0.3; } 100% { opacity: 0; }
}
.crit-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at center, rgba(255,215,0,0.15) 0%, transparent 70%);
  pointer-events: none; z-index: 90;
  animation: crit-screen-flash 0.4s ease-out forwards;
}

/* Gold gain flash */
@keyframes gold-flash { 0% { color: var(--gold); text-shadow: 0 0 6px rgba(255,215,0,0.6); } 100% { color: inherit; text-shadow: none; } }
.gold-flash { animation: gold-flash 0.8s ease-out; }

/* Tab unlock slide */
@keyframes tab-slide-in { 0% { transform: translateX(20px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
.tab-new { animation: tab-slide-in 0.4s ease-out; }

/* Assignment complete */
@keyframes assignment-complete { 0% { box-shadow: 0 0 0 0 rgba(255,215,0,0.6); } 50% { box-shadow: 0 0 12px 2px rgba(255,215,0,0.3); } 100% { box-shadow: none; } }

/* Card play animation */
@keyframes card-play { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-20px); opacity: 0; } }
.spell-card.casting { animation: card-play 0.3s ease-out forwards; pointer-events: none; }

/* Card draw animation */
@keyframes card-draw { 0% { transform: translateX(-15px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
.spell-card.drawn { animation: card-draw 0.25s ease-out; }

/* Ghost HP bar */
.bar-ghost {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
  background: rgba(255,255,255,0.15);
  transition: width 0.8s ease-out;
}

/* ---- QUILL LOG STYLING ---- */
.log-sidebar .log-entry { padding: 2px 4px; border-radius: 2px; }
.log-sidebar .log-entry.system { border-left: 2px solid var(--cast); padding-left: 6px; background: color-mix(in srgb, var(--cast) 4%, transparent); margin: 3px 0; border-radius: 0 2px 2px 0; }
.log-sidebar .log-entry.crit { border-left: 2px solid var(--crit); padding-left: 6px; background: rgba(232,200,64,0.04); margin: 3px 0; border-radius: 0 2px 2px 0; }
.log-sidebar .log-entry.kill { border-left: 2px solid var(--text-bright); padding-left: 6px; background: rgba(255,255,255,0.03); margin: 3px 0; border-radius: 0 2px 2px 0; }
.log-sidebar .log-entry.death { border-left: 2px solid var(--fizzle); padding-left: 6px; background: rgba(224,80,64,0.04); margin: 3px 0; border-radius: 0 2px 2px 0; }
.log-sidebar .log-entry.rival { padding-left: 6px; margin: 3px 0; border-radius: 0 2px 2px 0; font-style: italic; }

/* ---- COLLAPSIBLE SECTIONS ---- */
details { margin-bottom: 8px; }
details summary {
  user-select: none;
  font-family: Georgia, serif;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: var(--text-bright);
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--cast) 50%, var(--border));
}
details summary:hover { border-color: color-mix(in srgb, var(--cast) 60%, var(--border)); }
details summary::-webkit-details-marker { display: none; }
details[open] > summary {
  border-color: var(--border-light);
  background: none;
}
details > div, details > section { padding-top: 6px; }
.tri::after { content: '▸'; }
details[open] > summary .tri::after { content: '▾'; }
details details { margin-bottom: 4px; }
details details > summary { font-size: 12px; padding: 5px 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .game-layout { flex-direction: column; height: auto; min-height: calc(100vh - 74px); }
  .log-sidebar { width: 100%; min-width: 100%; height: 120px; min-height: 120px; border-right: none; border-bottom: 1px solid var(--border); box-shadow: none; order: -1; }
  .game-main { flex: 1; height: auto; min-height: 0; overflow-y: auto; }
  .tab-content { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .tab-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 10px; font-size: 11px; min-width: max-content; }
}
@media (max-width: 600px) {
  .game-header { padding: 8px 12px; }
  .game-title { font-size: 14px; letter-spacing: 2px; }
  #header-location { font-size: 11px; text-align: right; line-height: 1.3; }
  .resource-panel { gap: 4px; padding: 6px 8px; flex-wrap: wrap; }
  .resource-bar { min-width: 80px; flex: 1 1 auto; }
  .bar-track.thick { height: 10px; }
  .pip-display { font-size: 11px; }
  .log-sidebar { height: 100px; min-height: 100px; }
  .log-sidebar .combat-log { font-size: 10px; }
  .tab-btn { font-size: 10px; padding: 8px 8px; }
  .tab-content { padding: 10px 8px; }
  .btn { font-size: 11px; padding: 5px 10px; min-height: 32px; touch-action: manipulation; }
  .btn.primary { min-height: 36px; }
  select, input[type="text"] { font-size: 14px; min-height: 32px; touch-action: manipulation; }
  .section-head { font-size: 13px; padding: 8px 0; }
  .status-box { padding: 8px; }
  .rule-row { flex-wrap: wrap; gap: 4px; }
  .rule-row select { min-width: 120px; font-size: 13px; min-height: 34px; }
  .rule-row .btn { min-height: 30px; font-size: 11px; }
  .spell-card { min-width: 100px; }
  .enemy-card { padding: 8px; }
  .ss-container { padding: 30px 12px; }
  .ss-grid { grid-template-columns: 1fr; gap: 8px; }
  .ss-card { padding: 14px; }
  .ss-name-input { font-size: 16px; padding: 10px 14px; }
  details summary { padding: 8px 0; }
}

.mobile-tooltip {
  position: fixed;
  z-index: 200;
  background: #1e1e22;
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  pointer-events: auto;
  font-family: Georgia, serif;
}

/* ---- SCHOOL SELECTION SCREEN ---- */
#school-select {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center 30%, #151518 0%, #09090c 60%, #050508 100%);
  z-index: 100; overflow-y: auto;
}

#school-select::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center 15%, rgba(232,200,64,0.04) 0%, transparent 45%);
  pointer-events: none;
}

.ss-container {
  max-width: 560px; margin: 0 auto; padding: 50px 20px;
  text-align: center; position: relative;
}

.ss-title {
  font-size: 28px; color: #ede8e0; letter-spacing: 8px;
  font-family: Georgia, serif; text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.ss-title span {
  color: #e8c840;
  text-shadow: 0 0 20px rgba(232,200,64,0.35), 0 0 40px rgba(232,200,64,0.12);
}

.ss-divider {
  width: 140px; height: 1px; margin: 0 auto 32px;
  background: linear-gradient(90deg, transparent, #a08828, #e8c840, #f0d860, #e8c840, #a08828, transparent);
  box-shadow: 0 0 10px rgba(232,200,64,0.2), 0 0 3px rgba(232,200,64,0.1);
}

.ss-divider-sm {
  width: 60px; height: 1px; margin: 20px auto;
  background: linear-gradient(90deg, transparent, #454548, #555558, #454548, transparent);
}

.ss-label {
  font-size: 10px; color: #68605a; letter-spacing: 3px;
  text-transform: uppercase; font-family: Georgia, serif;
  margin-bottom: 12px; position: relative; display: inline-block;
}

.ss-label::before, .ss-label::after {
  content: ''; position: absolute; top: 50%;
  width: 30px; height: 1px;
  background: linear-gradient(90deg, transparent, #353538);
}
.ss-label::before { right: calc(100% + 10px); }
.ss-label::after { left: calc(100% + 10px); transform: scaleX(-1); }

.ss-name-input {
  background: #0c0c0f; border: 1px solid rgba(232,200,64,0.12);
  border-radius: 2px; padding: 10px 16px; font-family: Georgia, serif;
  font-size: 14px; color: #ede8e0; text-align: center; width: 260px;
  margin-bottom: 28px; outline: none;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.02);
  transition: all 0.3s;
}
.ss-name-input:focus {
  border-color: rgba(232,200,64,0.4);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 0 12px rgba(232,200,64,0.06);
}

.ss-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}

.ss-card {
  background: linear-gradient(180deg, #141418 0%, #0c0c0f 100%);
  border: 1px solid var(--card-color, #35353a);
  border-radius: 2px; padding: 0; cursor: pointer;
  transition: all 0.35s ease; text-align: left;
  box-shadow: 0 3px 12px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative; overflow: hidden;
}

.ss-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--card-color, transparent);
  opacity: 0.4; transition: opacity 0.35s;
}

.ss-card::after {
  content: ''; position: absolute; inset: 0;
  border-radius: 2px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0);
  transition: box-shadow 0.35s;
  pointer-events: none;
}

.ss-card-inner {
  padding: 20px 16px;
}

.ss-card:hover {
  border-color: var(--card-color, #35353a);
  transform: translateY(-2px);
  box-shadow:
    0 6px 24px rgba(0,0,0,0.7),
    0 0 24px var(--card-glow, rgba(255,255,255,0.05)),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.ss-card:hover::before { opacity: 1; }
.ss-card:hover::after {
  box-shadow: inset 0 0 30px var(--card-glow, rgba(255,255,255,0.03));
}

.ss-card .school-name {
  font-size: 18px; margin-bottom: 6px; font-family: Georgia, serif;
  color: var(--card-color);
}
.ss-card .school-desc {
  font-size: 11px; color: #888; line-height: 1.5;
}
.ss-card .school-meta {
  font-size: 10px; color: var(--card-color);
  opacity: 0.35; margin-top: 8px;
}

.ss-card[data-school="storm"] { --card-color: #9c7cf2; --card-glow: rgba(156,124,242,0.08); }
.ss-card[data-school="fire"] { --card-color: #f06040; --card-glow: rgba(240,96,64,0.08); }
.ss-card[data-school="ice"] { --card-color: #4fc3f7; --card-glow: rgba(79,195,247,0.06); }
.ss-card[data-school="life"] { --card-color: #66bb6a; --card-glow: rgba(102,187,106,0.06); }
.ss-card[data-school="death"] { --card-color: #8a8a9a; --card-glow: rgba(138,138,154,0.06); }
.ss-card[data-school="myth"] { --card-color: #e8b830; --card-glow: rgba(232,184,48,0.06); }

.ss-balance-note {
  font-size: 10px; color: #4a4440; margin-bottom: 10px;
  font-family: Georgia, serif;
}

.ss-card-balance {
  background: linear-gradient(180deg, #141418 0%, #0c0c0f 100%);
  border: 1px solid rgba(212,184,150,0.12);
  border-radius: 2px; padding: 14px 20px; cursor: pointer;
  transition: all 0.35s; max-width: 280px; margin: 0 auto;
  text-align: left; position: relative; overflow: hidden;
  box-shadow: 0 3px 12px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
}
.ss-card-balance::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #9c7cf2, #f06040, #e8b830, #66bb6a, #4fc3f7, #8a8a9a);
  opacity: 0.5; transition: opacity 0.35s;
}
.ss-card-balance:hover {
  border-color: rgba(212,184,150,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 16px rgba(212,184,150,0.06);
}
.ss-card-balance:hover::before { opacity: 1; }

.ss-version {
  font-size: 9px; color: #252528; margin-top: 30px;
  font-family: Georgia, serif;
}