/* ==========================================================================
   Runeforge Alchemists — Cozy Pastel Storybook 16:9 Commercial Game GUI
   Palette Locked to Concept Art: #734A37, #DFC29F, #FAECCB, #B6AC8E, #B88E69, #897F6B
   Typography: Fredoka / M PLUS Rounded 1c (Display) + Quicksand (Body/HUD)
   ========================================================================== */

:root {
  --ink: #5A3E36;
  --ink-warm: #734A37;
  --cream: #FFFDF7;
  --paper: #FAECCB;
  --sand: #DFC29F;
  --wood: #B88E69;
  --sage: #B6AC8E;
  --taupe: #897F6B;
  --ember: #D96B4B;
  --tide: #5B9EBF;
  --verdant: #7BA356;
  --solar: #E0AC3E;
  --font-display: 'Fredoka', 'M PLUS Rounded 1c', 'Trebuchet MS', sans-serif;
  --font-body: 'Quicksand', 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #734A37;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(12px, 0.92vw, 15px);
  line-height: 1.28;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] {
  display: none !important;
}

img {
  object-fit: contain;
  display: block;
}

h1, h2, h3, p {
  margin: 0;
}

/* ── 9-SLICE ANTI-DISTORTION LAW (EXACT MANIFEST SLICES, NO STACKED BORDERS) ── */
.panel-9slice {
  background: transparent;
  border: 20px solid transparent;
  border-image: url('../assets/ui/frame_panel.png') 73 77 77 77 fill / 20px stretch;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 5px 10px rgba(62, 38, 25, 0.28));
}

.btn-9slice {
  background: transparent;
  border: 14px solid transparent;
  border-image: url('../assets/ui/btn_primary.png') 90 81 89 82 fill / 14px stretch;
  border-radius: 0;
  box-shadow: none;
  color: #241B15;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(13px, 1.05vw, 17px);
  min-height: 50px;
  padding: 2px 16px;
  cursor: pointer;
  position: relative;
  overflow: visible !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  filter: drop-shadow(0 3px 0 rgba(90, 62, 54, 0.42));
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-9slice:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06) drop-shadow(0 4px 0 rgba(90, 62, 54, 0.45));
}

.btn-9slice:active:not(:disabled) {
  transform: translateY(2px);
  filter: drop-shadow(0 1px 0 rgba(90, 62, 54, 0.45));
}

/* ── SCULPTED COZY WOOD/CREAM TACTILE BUTTONS (OVERFLOW VISIBLE FOR RED-DOTS) ── */
button {
  font-family: inherit;
  color: inherit;
  overflow: visible !important;
  position: relative;
}

.btn-cozy {
  background: linear-gradient(180deg, #FFFDF7 0%, #F4DFB9 100%);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(11px, 0.88vw, 14px);
  line-height: 1.15;
  min-height: 42px;
  padding: 6px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-cozy:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-cozy:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

button:disabled {
  cursor: default;
  opacity: 0.56;
  filter: saturate(0.4);
}

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--solar);
  outline-offset: 2px;
}

.btn-label {
  display: inline-block;
  min-width: 0;
  line-height: 1.15;
}

.mini-btn-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sys-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

kbd {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  background: #FFFDF7;
  color: var(--ink);
  border: 1.5px solid var(--wood);
  border-radius: 5px;
  padding: 1px 5px;
  box-shadow: 0 1px 0 var(--wood);
}

/* ── REACTIVE RED-DOT NOTIFICATION BADGE (NEVER CLIPPED!) ── */
.notify-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 35;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #D9483B;
  color: #FFFDF7;
  border: 2px solid #FFFDF7;
  box-shadow: 0 2px 4px rgba(90, 62, 54, 0.45);
  font-family: var(--font-display);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
  animation: pulseBadge 1.8s ease-in-out infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.16); }
}

/* ── APP CONTAINER & TOP COMMAND BAR ── */
#game-app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: url('../assets/art/title_bg.jpg') center / cover no-repeat;
}

#topbar {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: linear-gradient(180deg, #FFF9EC 0%, #F2DEC0 100%);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 3px 10px rgba(90, 62, 54, 0.22);
  z-index: 25;
}

body.founder-theme #topbar {
  background: linear-gradient(180deg, #FFF7DF 0%, #F3D599 100%);
  border-bottom-color: #8C5C26;
}

.brand-btn {
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 2px 6px;
}

.brand-crest {
  width: 34px;
  height: 34px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1;
}

.brand-copy strong {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink-warm);
}

.brand-copy small {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--taupe);
  margin-top: 2px;
}

.stage-banner {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#topbar-stage-title {
  background: #FFFDF7;
  border: 2px solid var(--wood);
  border-radius: 999px;
  padding: 4px 16px;
  font-family: var(--font-display);
  font-size: clamp(12px, 1vw, 15px);
  color: var(--ink);
  box-shadow: inset 0 1px 0 #FFFFFF;
}

.hud-currencies {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFDF7;
  border: 2px solid var(--wood);
  border-radius: 999px;
  padding: 3px 11px 3px 6px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-height: 36px;
}

.hud-pill img {
  width: 26px;
  height: 26px;
}

.hud-pill-btn {
  cursor: pointer;
}

.pill-plus {
  background: var(--verdant);
  color: #FFFDF7;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  font-weight: 800;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-action-btn {
  min-height: 38px;
  padding: 4px 10px;
}

.hud-action-btn img {
  width: 22px;
  height: 22px;
}

.icon-only-btn {
  min-height: 38px;
  width: 40px;
  padding: 4px;
}

.hud-quit-btn {
  min-height: 38px;
  background: linear-gradient(180deg, #FFEFE9 0%, #F4CBBF 100%);
}

/* ── SCENES ── */
.scene {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

/* ── SCENE 1: TITLE SCREEN ── */
.title-scene {
  background: linear-gradient(90deg, rgba(250, 236, 203, 0.32) 0%, rgba(115, 74, 55, 0.14) 100%),
              url('../assets/art/title_bg.jpg') center / cover no-repeat;
  display: flex;
  align-items: center;
  padding: 0 6vw;
}

.title-top-controls {
  position: absolute;
  top: 18px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFDF7;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 5px 10px;
  box-shadow: 0 3px 0 var(--ink);
}

.lang-pill select {
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.title-hero-wrap {
  width: min(560px, 92vw);
}

.title-card {
  padding: 22px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-warm);
  text-transform: uppercase;
}

.display-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(36px, 4.3vw, 64px);
  line-height: 1.02;
  color: #FFF9EE;
  -webkit-text-stroke: 2.2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
}

.display-title span {
  color: #FFE094;
}

.title-tagline {
  font-size: clamp(13px, 1.05vw, 16px);
  color: var(--ink);
  max-width: 440px;
}

.title-runes-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0;
}

.title-runes-row img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 2px rgba(90, 62, 54, 0.35));
}

.title-runes-row img.sword-center {
  width: 50px;
  height: 50px;
}

.boot-loader {
  width: 84%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.load-track {
  height: 16px;
  background: #E5CEAC;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  padding: 2px;
}

.load-fill {
  height: 100%;
  background: linear-gradient(90deg, #86B361 0%, #B8D87E 100%);
  border-radius: 999px;
  transition: width 0.14s ease-out;
}

.load-label {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink);
}

.title-play-btn {
  min-width: 240px;
  min-height: 60px;
  font-size: clamp(17px, 1.4vw, 22px);
  margin-top: 4px;
}

/* ── SCENE 2: WORKSHOP CAMPFIRE HUB ── */
.hub-scene {
  background: linear-gradient(180deg, rgba(250, 236, 203, 0.25), rgba(115, 74, 55, 0.28)),
              url('../assets/art/arena_bg.jpg') center / cover no-repeat;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
}

.hub-layout {
  width: min(1760px, 96vw);
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.hub-stage-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 4px 10px;
}

.hub-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hub-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 1.8vw, 30px);
  color: var(--ink-warm);
}

.hub-battle-cta {
  min-width: 220px;
}

.hub-canvas-frame {
  flex: 1;
  min-height: 0;
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: url('../assets/art/arena_bg.jpg') center / cover no-repeat;
}

#hub-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.crucible-float-btn {
  position: absolute;
  right: 16px;
  bottom: 14px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #FFFDF7 0%, #F7DFA8 100%);
}

.crucible-float-btn img {
  width: 30px;
  height: 30px;
}

.hub-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 6px 10px;
}

.hub-nav-btn {
  min-height: 54px;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
}

.hub-nav-btn .hub-btn-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hub-nav-btn img {
  width: 26px;
  height: 26px;
}

.hub-lock-tag {
  font-size: 10px;
  color: var(--taupe);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ── SCENE 3: 3-COLUMN 16:9 DESKTOP BATTLE SCREEN (>= 94% VIEWPORT WIDTH!) ── */
.battle-scene {
  background: linear-gradient(180deg, rgba(250, 236, 203, 0.16), rgba(90, 62, 54, 0.28)),
              url('../assets/art/title_bg.jpg') center / cover no-repeat;
  padding: 8px 14px;
}

.battle-grid {
  width: min(1840px, 98vw);
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 23.5fr 53fr 23.5fr;
  gap: 12px;
  min-height: 0;
}

.col-roster, .col-tactics {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 6px;
}

.col-heading {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.25vw, 20px);
  color: var(--ink-warm);
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--wood);
}

.roster-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.roster-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #FFFDF7 0%, #F5E5C8 100%);
  border: 2px solid var(--wood);
  border-radius: 12px;
  padding: 5px 8px;
  min-width: 0;
  min-height: 0;
  box-shadow: inset 0 1px 0 #FFFFFF;
}

.roster-card.locked-slot {
  opacity: 0.78;
  background: #EFE1C6;
  border-style: dashed;
}

.roster-portrait {
  width: clamp(42px, 3.6vw, 58px);
  height: clamp(42px, 5.8vh, 62px);
  border-radius: 10px;
  background: #EAD4B0;
  border: 1.5px solid var(--wood);
  flex-shrink: 0;
}

.roster-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.roster-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.roster-name-row strong {
  font-family: var(--font-display);
  font-size: clamp(12px, 0.92vw, 15px);
  color: var(--ink);
}

.roster-elem-icon {
  width: 18px;
  height: 18px;
}

.roster-meta {
  font-size: 11px;
  color: var(--taupe);
}

.bar-track {
  width: 100%;
  height: 8px;
  background: #D5BE9C;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.18s ease-out;
}

.bar-fill.hp-fill {
  background: linear-gradient(90deg, #7BA356, #A8CC76);
}

.bar-fill.en-fill {
  background: linear-gradient(90deg, #5B9EBF, #87CBEB);
}

.synergy-box {
  background: #F6E6C9;
  border: 2px solid var(--wood);
  border-radius: 11px;
  padding: 6px 8px;
  text-align: center;
}

.synergy-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.synergy-runes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.synergy-runes img {
  width: 24px;
  height: 24px;
}

.roster-footer-btns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.roster-footer-btns > * {
  min-width: 0;
}

/* ── CENTER COLUMN: ARENA + SKILLS + 6x5 TRAY ── */
.col-center {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 43fr 11.5fr 45.5fr;
  gap: 7px;
}

.arena-wrap {
  position: relative;
  min-height: 0;
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: url('../assets/art/arena_bg.jpg') center / cover no-repeat;
  box-shadow: 0 4px 12px rgba(62, 38, 25, 0.25);
}

#arena-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.arena-hud-top {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 12;
}

.arena-tag {
  background: rgba(255, 253, 247, 0.92);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sword-tag img {
  width: 18px;
  height: 18px;
}

.boss-tag {
  background: #FFE8DF;
  border-color: #9E3D2B;
  color: #8C2D1C;
}

.flying-corridor {
  position: absolute;
  left: 0;
  right: 0;
  top: 25%;
  height: 22%;
  z-index: 45;
  pointer-events: none;
}

.flying-bonus-orb {
  position: absolute;
  top: 10%;
  left: -60px;
  pointer-events: auto;
  background: rgba(255, 250, 230, 0.85);
  border: 2px solid var(--solar);
  border-radius: 999px;
  padding: 4px 10px 4px 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(224, 172, 62, 0.55);
  animation: flyAcross 12s linear forwards;
}

.flying-bonus-orb img {
  width: 28px;
  height: 28px;
}

@keyframes flyAcross {
  0% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(42vw) translateY(-10px); }
  100% { transform: translateX(55vw) translateY(4px); }
}

/* ── 4-PHASE ULTIMATE CUT-IN PANEL (STORYBOOK PARCHMENT & BRASS) ── */
.cutin-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(26, 17, 13, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.cutin-band {
  width: 104%;
  background: linear-gradient(95deg, #5A3E36 0%, #FFF7E4 14%, #FAECCB 82%, #D8A45B 100%);
  border-top: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  box-shadow: 0 8px 24px rgba(34, 20, 12, 0.55);
  transform: rotate(-2.2deg);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 26px;
  animation: cutinSlide 0.46s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.cutin-overlay.fast-cutin .cutin-band {
  animation-duration: 0.24s;
}

.cutin-overlay.boss-cutin .cutin-band {
  background: linear-gradient(95deg, #6E251A 0%, #FFE8D9 16%, #F9D2B8 84%, #B85D38 100%);
}

@keyframes cutinSlide {
  0% { transform: translateX(-45%) rotate(-2.2deg) scale(0.94); opacity: 0; }
  28% { transform: translateX(0%) rotate(-2.2deg) scale(1.02); opacity: 1; }
  82% { transform: translateX(1%) rotate(-2.2deg) scale(1); opacity: 1; }
  100% { transform: translateX(22%) rotate(-2.2deg) scale(0.98); opacity: 0; }
}

.cutin-portrait-frame {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: #FFFDF7;
  border: 3.5px solid var(--ink);
  box-shadow: 0 0 0 3px #E6B86A;
  overflow: hidden;
  flex-shrink: 0;
}

.cutin-portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cutin-copy {
  flex: 1;
  min-width: 0;
}

.cutin-eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-warm);
}

.cutin-skill-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 2vw, 30px);
  color: #FFF9EE;
  -webkit-text-stroke: 1.8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--ink);
  line-height: 1.05;
}

.cutin-skill-sub {
  font-size: 12px;
  color: var(--ink);
  margin-top: 2px;
}

.cutin-rune-badge {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 4px rgba(90, 62, 54, 0.4));
}

.overdrive-bar-wrap {
  position: absolute;
  bottom: 6px;
  left: 16%;
  right: 16%;
  z-index: 12;
  background: rgba(255, 253, 247, 0.92);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.overdrive-label {
  font-family: var(--font-display);
  color: var(--ink-warm);
  white-space: nowrap;
}

.overdrive-track {
  flex: 1;
  height: 8px;
  background: #DEC6A4;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.overdrive-fill {
  height: 100%;
  background: linear-gradient(90deg, #E0AC3E, #F27D52, #FFE37E);
  transition: width 0.2s ease;
}

/* ── MIDDLE SKILL DECK (4 HERO SKILL CARDS) ── */
.skill-deck {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  min-height: 0;
}

.skill-card-btn {
  background: linear-gradient(180deg, #FFFBF0 0%, #EED5B0 100%);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 4px 7px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  text-align: left;
}

.skill-card-btn.skill-ready {
  background: linear-gradient(180deg, #FFFDF2 0%, #FFE08C 100%);
  border-color: #9E631B;
  box-shadow: 0 0 12px rgba(224, 172, 62, 0.78), 0 3px 0 #734A37;
  animation: skillPulse 1.3s ease-in-out infinite;
}

@keyframes skillPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.skill-card-btn img.skill-portrait {
  width: clamp(34px, 3vw, 46px);
  height: clamp(34px, 5vh, 46px);
  border-radius: 8px;
  border: 1.5px solid var(--wood);
  background: #EAD4B0;
  flex-shrink: 0;
}

.skill-card-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.skill-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 11px;
}

.skill-card-top strong {
  font-family: var(--font-display);
  font-size: 12px;
}

/* ── BOTTOM 6x5 ELEMENTAL RUNESTONE TRAY (STORYBOOK WOOD & BRASS HANDLES) ── */
.board-tray-outer {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.board-handle {
  width: 18px;
  height: 52%;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, #DDA963, #A8763E);
}

.left-handle {
  border-right: none;
  border-radius: 14px 0 0 14px;
}

.right-handle {
  border-left: none;
  border-radius: 0 14px 14px 0;
}

.board-shell {
  height: 100%;
  width: min(100%, 540px);
  background: linear-gradient(180deg, #8B6043 0%, #6D4932 100%);
  border: 3.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: inset 0 2px 0 #C89B68, 0 5px 12px rgba(62, 38, 25, 0.32);
  padding: 7px 10px 4px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.board-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 4px;
  touch-action: none;
}

.rune-tile {
  background: url('../assets/ui/slot_tile.png') center / cover no-repeat;
  border: 1.5px solid rgba(72, 45, 29, 0.65);
  border-radius: 9px;
  padding: 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.16s ease, filter 0.12s ease;
}

.rune-tile:hover:not(:disabled) {
  filter: brightness(1.09);
}

.rune-tile img.rune-img {
  width: 78%;
  height: 82%;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(58, 34, 20, 0.45));
}

.rune-tile.selected {
  outline: 3px solid #FFF3A6;
  outline-offset: -2px;
  transform: scale(1.07);
  z-index: 4;
}

.rune-tile.hint-glow {
  outline: 4px solid #FFD447;
  outline-offset: -2px;
  box-shadow: 0 0 0 4px #FFF4B8, 0 0 20px 6px rgba(255, 196, 38, 0.95);
  z-index: 6;
  animation: hintPulse 0.72s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { transform: scale(1.02); filter: brightness(1.08); }
  50% { transform: scale(1.12); filter: brightness(1.38); }
}

.rune-tile.clearing {
  transform: scale(0.25);
  opacity: 0;
}

.rune-tile.invalid-shake {
  animation: invalidSwapBounce 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes invalidSwapBounce {
  0% { transform: translateX(0); }
  35% { transform: translateX(7px) scale(0.95); }
  70% { transform: translateX(-5px) scale(1.03); }
  100% { transform: translateX(0) scale(1); }
}

/* MyButtonTween (70ms EaseOutQuad press -> 110ms EaseOutBack release) */
.btn-cozy, .btn-9slice {
  transition: transform 0.11s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.12s ease;
}
.btn-cozy:active:not(:disabled), .btn-9slice:active:not(:disabled) {
  transform: scale(0.92);
  transition-duration: 0.07s;
  transition-timing-function: ease-out;
}

/* Trigger #8: UIShiny diagonal gloss sweep on 12/12 READY skill cards */
.skill-card.ready, .skill-card.skill-ready {
  position: relative;
  overflow: hidden;
}
.skill-card.ready::after, .skill-card.skill-ready::after {
  content: "";
  position: absolute;
  top: -20%;
  left: -75%;
  width: 45%;
  height: 140%;
  background: linear-gradient(105deg, rgba(255,255,255,0) 0%, rgba(255,250,220,0.65) 50%, rgba(255,255,255,0) 100%);
  transform: skewX(-22deg);
  pointer-events: none;
  animation: uiShinySweep 2.6s ease-in-out infinite;
}
@keyframes uiShinySweep {
  0%, 62% { left: -75%; }
  100% { left: 135%; }
}

/* Trigger #2: FIGHT! 1/2 Wave Banner */
.wave-banner-pop {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%) scale(0.4);
  padding: 8px 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFF7DC 0%, #F4CA6E 100%);
  border: 3px solid #5A3E36;
  color: #5A3E36;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(90, 62, 54, 0.35);
  pointer-events: none;
  z-index: 48;
  animation: fightBannerPop 0.98s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes fightBannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  26% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  38% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  82% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(0.95); }
}

/* Trigger #1: Baked Touch Effect soft radial ripple */
.touch-ripple {
  position: fixed;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 224, 116, 0.85);
  background: radial-gradient(circle, rgba(255, 248, 214, 0.45) 0%, rgba(255, 224, 116, 0) 70%);
  pointer-events: none;
  z-index: 9999;
  animation: touchRippleOut 0.46s ease-out forwards;
}
@keyframes touchRippleOut {
  0% { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

.rune-tile.weaved {
  animation: weaveFlash 0.45s ease-out;
}

@keyframes weaveFlash {
  0% { filter: brightness(2.1); transform: scale(1.16); }
  100% { filter: brightness(1); transform: scale(1); }
}

.special-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  background: var(--ink);
  color: #FFF7D6;
  border: 1.5px solid #FFE08A;
  border-radius: 6px;
  font-size: 10px;
  line-height: 12px;
  padding: 1px 4px;
  pointer-events: none;
}

.hazard-tag {
  position: absolute;
  inset: 2px;
  border-radius: 7px;
  pointer-events: none;
}

.hazard-vine {
  border: 3.5px solid #638F44;
  box-shadow: inset 0 0 8px rgba(74, 118, 45, 0.65);
}

.hazard-ore {
  border: 3.5px solid #8A9199;
  background: rgba(120, 128, 138, 0.28);
}

.board-footer {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 3px;
  color: var(--paper);
  font-size: 11px;
}

.hint-btn {
  min-height: 22px;
  padding: 1px 8px;
  font-size: 11px;
  border-radius: 8px;
  box-shadow: 0 1px 0 var(--ink);
}

/* ── RIGHT COLUMN: ELEMENT WHEEL, BATTLE CHRONICLE & CONTROLS ── */
.element-wheel-card {
  background: #F6E6C9;
  border: 2px solid var(--wood);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.element-wheel-ring {
  position: relative;
  width: min(128px, 14vh);
  height: min(128px, 14vh);
  margin: 4px auto 6px;
  border-radius: 50%;
  border: 6px solid var(--wood);
  background: conic-gradient(#E89B7E 0 90deg, #9EC27E 90deg 180deg, #87BFD6 180deg 270deg, #ECD07A 270deg 360deg);
}

.ew-node {
  position: absolute;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 2px rgba(90, 62, 54, 0.45));
}

.ew-top { top: -11px; left: calc(50% - 15px); }
.ew-right { right: -11px; top: calc(50% - 15px); }
.ew-bottom { bottom: -11px; left: calc(50% - 15px); }
.ew-left { left: -11px; top: calc(50% - 15px); }
.ew-center {
  position: absolute;
  width: 34px;
  height: 34px;
  left: calc(50% - 17px);
  top: calc(50% - 17px);
  background: #FFFDF7;
  border: 2px solid var(--ink);
  border-radius: 50%;
  padding: 3px;
}

.wheel-note {
  font-size: 11px;
  color: var(--ink-warm);
}

.battle-log {
  flex: 1;
  min-height: 60px;
  overflow-y: auto;
  background: #FFFDF7;
  border: 2px solid var(--wood);
  border-radius: 11px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
}

.log-entry {
  padding: 3px 4px;
  border-bottom: 1px solid #EFE0C4;
  color: var(--ink);
}

.tactics-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tactics-controls > * {
  min-width: 0;
}

.btn-cozy.toggled-on {
  background: linear-gradient(180deg, #E8F5D4 0%, #BFE09A 100%);
  border-color: #4D6B2A;
}

/* ── SPRING MODALS & STRICT `minmax(0, 1fr)` CONTAINMENT LAW ── */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(48, 30, 20, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fadeScrim 0.2s ease-out;
}

@keyframes fadeScrim {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(940px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 14px;
  animation: springModal 0.25s cubic-bezier(0.22, 1.28, 0.36, 1);
  min-width: 0;
}

@keyframes springModal {
  0% { transform: scale(0.84); opacity: 0; }
  70% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 2px dashed var(--wood);
}

.modal-header h2 {
  flex: 1;
  font-family: var(--font-display);
  font-size: clamp(18px, 1.6vw, 25px);
  color: var(--ink-warm);
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 6px;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.modal-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.modal-grid-2 > *, .modal-grid-3 > *, .modal-grid-4 > * {
  min-width: 0;
  max-width: 100%;
}

.item-card {
  background: linear-gradient(180deg, #FFFDF7 0%, #F5E5C8 100%);
  border: 2px solid var(--wood);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  position: relative;
}

.item-card img.card-art {
  width: 78px;
  height: 78px;
}

.item-card img.shop-pack-art {
  width: 96px;
  height: 96px;
}

.item-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink);
}

.item-card p {
  font-size: 12px;
  color: var(--taupe);
}

.ribbon-badge {
  position: absolute;
  top: -8px;
  left: 10px;
  background: #D96B4B;
  color: #FFFDF7;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.ribbon-badge.best {
  background: #E0AC3E;
  color: #241B15;
}

.coach-card {
  background: #FFF9E6;
  border: 2px dashed var(--wood);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── SETTINGS FORM ── */
.settings-row {
  background: #FFFDF7;
  border: 2px solid var(--wood);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-row-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-row input[type="range"] {
  width: 100%;
  accent-color: var(--verdant);
}

/* ── CHEST 3-BEAT & SUNBURST ── */
.chest-stage {
  text-align: center;
  padding: 16px;
}

.sunburst-ring {
  width: 190px;
  height: 190px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(224, 172, 62, 0.32) 0 15deg, transparent 15deg 30deg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spinSlow 10s linear infinite;
}

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

.chest-hero-img {
  width: 132px;
  height: 132px;
  animation: chestBounce 0.42s ease-in-out infinite alternate;
}

@keyframes chestBounce {
  from { transform: scale(0.96) rotate(-3deg); }
  to { transform: scale(1.05) rotate(3deg); }
}

/* ── INTERACTIVE FTUE TUTORIAL & TOASTS ── */
.tutorial-overlay {
  position: fixed;
  left: 50%;
  top: 66px;
  transform: translateX(-50%);
  width: min(600px, 88vw);
  z-index: 92;
  background: rgba(255, 253, 247, 0.97);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 8px 26px rgba(48, 30, 20, 0.36);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tutorial-overlay img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--wood);
  flex-shrink: 0;
}

.tutorial-copy {
  flex: 1;
  font-size: 13.5px;
  color: var(--ink);
}

.tut-spotlight {
  position: relative;
  z-index: 60 !important;
  outline: 3.5px solid #FFE27A !important;
  outline-offset: 3px;
  box-shadow: 0 0 18px rgba(255, 220, 100, 0.9) !important;
}

.toast-banner {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(12px);
  z-index: 160;
  background: var(--ink);
  color: #FFFDF7;
  border: 2px solid #FFE094;
  border-radius: 999px;
  padding: 9px 20px;
  font-family: var(--font-display);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#celebration-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 140;
}

/* ── PREVIEW-ONLY [DEV F2] PILL & SHOWCASE ── */
.dev-f2-pill {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 95;
  background: rgba(45, 32, 26, 0.85);
  color: #FFE599;
  border: 1.5px solid #D9A45B;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  min-height: 26px;
  cursor: pointer;
}

.showcase-stage-canvas {
  width: 100%;
  height: 240px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: url('../assets/art/arena_bg.jpg') center / cover no-repeat;
  display: block;
}

/* ── RESPONSIVE FALLBACK (< 1180px & < 900px) ── */
@media (max-width: 1340px) {
  #topbar {
    gap: 6px;
    padding: 4px 10px;
  }
  .hud-pill {
    padding: 2px 8px 2px 5px;
    font-size: 12px;
  }
  .battle-grid {
    grid-template-columns: 24fr 52fr 24fr;
    gap: 8px;
  }
  .panel-9slice {
    border-width: 14px;
  }
}

@media (max-width: 899px) {
  html, body {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }
  #game-app {
    height: auto;
    min-height: 100vh;
  }
  #topbar {
    flex-wrap: wrap;
    height: auto;
  }
  .battle-grid {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .col-center {
    order: 0;
    height: 760px;
  }
  .col-roster {
    order: 1;
  }
  .col-tactics {
    order: 2;
  }
  .modal-grid-3, .modal-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
