/* ==========================================================================
   Card Game Tools — Tactical Tabletop UI (v11 High-Craft Dark Edition)
   GPU-accelerated details, adaptive game accent themes, 0px overflow
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #080a0e;
  --bg-accent: #131822;
  --panel: #13161d;
  --panel-elevated: #191d26;
  --panel-subtle: #0e1016;
  --line: #252b37;
  --line-bright: #384152;
  --muted: #8a94a6;
  --text: #f3f5f9;
  --lime: #c8f564;
  --lime-dim: rgba(200, 245, 100, 0.13);
  --lime-glow: rgba(200, 245, 100, 0.35);
  --accent: var(--lime);
  --accent-dim: var(--lime-dim);
  --accent-glow: var(--lime-glow);
  --lav: #b8a7ff;
  --red: #ff6b75;
  --red-dim: rgba(255, 107, 117, 0.16);
  --amber: #ffca64;
  --blue: #70c0ff;
  --cyan: #5ce1e6;
  --sans: 'Inter', 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Manrope', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --board-cols: 2;
}

/* Per-Game Dynamic Atmospheric Accents */
body[data-game="magic"] {
  --accent: #c8f564;
  --accent-dim: rgba(200, 245, 100, 0.13);
  --accent-glow: rgba(200, 245, 100, 0.32);
}
body[data-game="pokemon"] {
  --accent: #ffd452;
  --accent-dim: rgba(255, 212, 82, 0.14);
  --accent-glow: rgba(255, 212, 82, 0.32);
}
body[data-game="yugioh"] {
  --accent: #b99aff;
  --accent-dim: rgba(185, 154, 255, 0.15);
  --accent-glow: rgba(185, 154, 255, 0.34);
}
body[data-game="onepiece"] {
  --accent: #ff7e6b;
  --accent-dim: rgba(255, 126, 107, 0.15);
  --accent-glow: rgba(255, 126, 107, 0.34);
}
body[data-game="lorcana"] {
  --accent: #68d8ff;
  --accent-dim: rgba(104, 216, 255, 0.14);
  --accent-glow: rgba(104, 216, 255, 0.32);
}
body[data-game="flesh"] {
  --accent: #ff9c59;
  --accent-dim: rgba(255, 156, 89, 0.14);
  --accent-glow: rgba(255, 156, 89, 0.32);
}
body[data-game="custom"] {
  --accent: #5ef2d6;
  --accent-dim: rgba(94, 242, 214, 0.14);
  --accent-glow: rgba(94, 242, 214, 0.32);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -12%, var(--accent-dim), transparent 65%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0);
  background-size: 100% 100%, 22px 22px;
  color: var(--text);
  font: 13px/1.35 var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

body.allow-page-scroll {
  height: auto;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Main Viewport Shell */
.app-shell {
  width: 100%;
  max-width: 1380px;
  height: 100dvh;
  margin: 0 auto;
  padding: 8px 10px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 7px;
  overflow: hidden;
}

body.allow-page-scroll .app-shell {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

/* ==========================================================================
   1. Topbar (Tactical HUD Header)
   ========================================================================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  min-width: 0;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  flex-shrink: 0;
}

.brand-picture {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: 124px;
  height: auto;
  max-height: 50px;
  object-fit: contain;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #212832 0%, #11141b 100%);
  color: var(--accent);
  font: 800 14px var(--display);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 14px var(--accent-dim),
    0 4px 10px rgba(0, 0, 0, 0.35);
  transition: color 0.2s, border-color 0.2s;
}

.brand:hover .brand-mark {
  border-color: var(--accent);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font: 800 14px/1.1 var(--display);
  letter-spacing: -0.4px;
  white-space: nowrap;
}

.brand-title b {
  color: var(--accent);
  transition: color 0.2s;
}

.brand small {
  font: 600 7.5px/1 var(--mono);
  color: var(--muted);
  letter-spacing: 1.4px;
  margin-top: 2px;
}

.session-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: linear-gradient(180deg, #171b24 0%, #11141c 100%);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 700 9.5px var(--mono);
  letter-spacing: 0.7px;
  color: #cfd6e2;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 3px 10px rgba(0, 0, 0, 0.25);
}

.session-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-dot, .offline-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  flex-shrink: 0;
}

.separator {
  color: #4f5868;
  flex-shrink: 0;
}

#turn-label {
  flex-shrink: 0;
  color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.offline-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--accent-dim);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font: 700 8.5px var(--mono);
  letter-spacing: 0.6px;
  color: var(--text);
  white-space: nowrap;
}

.offline-badge.offline-active i {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.lang-top-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 31px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1b1f29 0%, #13161e 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.lang-top-wrap:hover,
.lang-top-wrap:focus-within {
  border-color: var(--accent);
}

.lang-badge-label {
  font: 800 10.5px/1 var(--mono);
  letter-spacing: 0.5px;
  color: var(--accent);
  pointer-events: none;
}

.lang-quick-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: 0;
}

.lang-quick-select option,
.setting-select option {
  background: #151922;
  color: var(--text);
  font-family: var(--sans);
}

.setting-select {
  min-width: 170px;
  height: 32px;
  padding: 4px 8px;
  font-size: 11.5px;
}

.icon-button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1b1f29 0%, #13161e 100%);
  color: #d0d6e0;
  width: 31px;
  height: 31px;
  border-radius: 8px;
  font-size: 14px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.12s, border-color 0.15s, color 0.15s;
}

.icon-button:hover, .icon-button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(180deg, #222834 0%, #161a23 100%);
}

.icon-button:active {
  transform: scale(0.94);
}

/* ==========================================================================
   2. Control Bar (Pickers + Action Buttons)
   ========================================================================== */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #171b24 0%, #12151c 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.25);
}

.picker-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  flex: 1 1 340px;
  min-width: 0;
  width: 100%;
}

.picker-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0d1016;
  border: 1px solid #242a36;
  border-radius: 8px;
  padding: 2px 8px;
  min-width: 0;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s;
}

.picker-field:focus-within {
  border-color: var(--accent);
}

.picker-field label {
  font: 700 8px var(--mono);
  letter-spacing: 0.9px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

select, input {
  font: 600 12px var(--sans);
  color: var(--text);
  background: #181c25;
  border: 1px solid #2f3645;
  border-radius: 7px;
  padding: 5px 8px;
  outline: none;
  min-width: 0;
  max-width: 100%;
}

.picker-field select {
  background: transparent;
  border: 0;
  padding: 4px 0;
  width: 100%;
  min-width: 0;
  cursor: pointer;
  text-overflow: ellipsis;
}

.picker-field select option {
  background: #161a22;
  color: var(--text);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.utility-action {
  width: 30px;
  height: 30px;
}

.action-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font: 600 11px var(--sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.1s, border-color 0.15s, background 0.15s, color 0.15s;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-label-short {
  display: none;
}

.quiet-button {
  border: 1px solid #282f3d;
  background: linear-gradient(180deg, #1b1f29 0%, #13161e 100%);
  color: #bec7d6;
}

.quiet-button:hover:not(:disabled) {
  border-color: #465063;
  color: var(--text);
  background: linear-gradient(180deg, #232834 0%, #171b24 100%);
}

.quiet-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.customize-button {
  border: 1px solid rgba(200, 245, 100, 0.35);
  background: linear-gradient(180deg, rgba(200, 245, 100, 0.16) 0%, rgba(200, 245, 100, 0.06) 100%);
  color: var(--lime);
}

.customize-button:hover {
  border-color: var(--lime);
  background: linear-gradient(180deg, rgba(200, 245, 100, 0.24) 0%, rgba(200, 245, 100, 0.1) 100%);
}

.new-game {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(180deg, #d7fc82 0%, #b7e84f 100%);
  color: #101606;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 3px 10px rgba(200, 245, 100, 0.2);
}

.new-game:hover {
  background: linear-gradient(180deg, #e0ff96 0%, #c6f361 100%);
}

/* ==========================================================================
   3. Layout Edit Banner
   ========================================================================== */
.layout-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: linear-gradient(90deg, rgba(200, 245, 100, 0.14), rgba(20, 25, 33, 0.96));
  border: 1px solid #4d5f36;
  border-radius: 9px;
  font-size: 10.5px;
  min-width: 0;
}

.layout-banner[hidden] {
  display: none !important;
}

.layout-banner-info {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #dce4ee;
}

.pulse-badge {
  background: var(--lime);
  color: #141a0b;
  font: 800 8.5px var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.layout-banner-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.banner-btn {
  height: 25px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid #4a5564;
  background: #1b2029;
  color: var(--text);
  font: 600 10.5px var(--sans);
  cursor: pointer;
}

.banner-btn.primary {
  background: var(--lime);
  border-color: var(--lime);
  color: #13190a;
  font-weight: 700;
}

/* ==========================================================================
   4. Smart Viewport Board Grid & High-Craft Tool Cards
   ========================================================================== */
.board {
  display: grid;
  grid-template-columns: repeat(var(--board-cols, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  grid-auto-flow: dense;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #313744 transparent;
}

/* Tool Card Window — Layered metallic dark surface with top specular rim */
.tool-card {
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.035) 0%, transparent 55%),
    linear-gradient(165deg, #181c25 0%, #11141b 100%);
  border: 1px solid #262c38;
  border-radius: var(--radius-lg);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 22px rgba(0, 0, 0, 0.36);
  contain: layout style;
  transition: border-color 0.18s;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: 0.65;
  pointer-events: none;
}

.tool-card:hover {
  border-color: #363f52;
}

/* Column & Row Spanning */
.tool-card.col-span-1 { grid-column: span 1; }
.tool-card.col-span-2 { grid-column: span 2; }
.tool-card.col-span-3 { grid-column: span 3; }
.tool-card.col-span-4 { grid-column: span 4; }
.tool-card.row-span-2 { grid-row: span 2; }

/* Card Header */
.tool-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.tool-label {
  display: flex;
  gap: 6px;
  align-items: center;
  text-transform: uppercase;
  font: 700 9px var(--mono);
  letter-spacing: 0.85px;
  color: #c2cad8;
  min-width: 0;
  flex: 1;
}

.tool-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-icon {
  width: 19px;
  height: 19px;
  border-radius: 5px;
  background: var(--accent-dim);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tool-top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mini-add-btn {
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid rgba(200, 245, 100, 0.28);
  background: linear-gradient(180deg, rgba(200, 245, 100, 0.12) 0%, rgba(200, 245, 100, 0.04) 100%);
  color: var(--lime);
  font: 700 8.5px var(--mono);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.mini-add-btn:hover {
  background: rgba(200, 245, 100, 0.2);
  border-color: var(--lime);
}

.mini-add-btn:active {
  transform: scale(0.95);
}

.card-menu {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #7d8694;
  font-size: 13px;
  width: 21px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.card-menu:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel-subtle);
}

/* Layout Controls bar inside each card */
.card-layout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 3px 5px;
  margin-bottom: 5px;
  background: rgba(200, 245, 100, 0.1);
  border: 1px dashed rgba(200, 245, 100, 0.45);
  border-radius: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.card-layout-bar button {
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid #3a4350;
  background: #171b22;
  color: #d6dde8;
  font: 700 8.5px var(--mono);
  cursor: pointer;
}

.card-layout-bar button.active {
  background: var(--lime);
  color: #13190a;
  border-color: var(--lime);
}

/* Scrollable body inside cards so windows NEVER clip data */
.tool-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #343b48 transparent;
  gap: 6px;
}

/* ==========================================================================
   5. Life Counter Card (With Dynamic Health Progress Bar & Delta Badge)
   ========================================================================== */
.life-players {
  display: grid;
  gap: 7px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  align-content: stretch;
}

.life-players.players-1 { grid-template-columns: 1fr; }
.life-players.players-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.life-players.players-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.life-players.players-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.life-player {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(255, 255, 255, 0.03) 0%, transparent 70%),
    linear-gradient(180deg, #12161e 0%, #0d1016 100%);
  border: 1px solid #262c38;
  border-radius: 11px;
  padding: 7px 7px 6px;
  min-width: 0;
  min-height: 0;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s;
}

.life-player.is-low-life {
  border-color: rgba(255, 107, 117, 0.45);
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(255, 107, 117, 0.08) 0%, transparent 70%),
    linear-gradient(180deg, #191217 0%, #110c10 100%);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  position: relative;
}

.player-name-input {
  display: block;
  width: 100%;
  height: 19px;
  min-height: 0;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #a6b0c0;
  text-align: center;
  font: 700 9px var(--mono);
  letter-spacing: 0.8px;
}

.player-name-input:hover, .player-name-input:focus {
  border-color: #3a414f;
  background: #161920;
  color: var(--text);
}

.life-delta-pill {
  position: absolute;
  right: 2px;
  top: 0;
  padding: 1px 5px;
  border-radius: 999px;
  font: 800 8.5px var(--mono);
  pointer-events: none;
  animation: deltaPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.life-delta-pill.gain {
  background: rgba(200, 245, 100, 0.16);
  color: var(--lime);
  border: 1px solid rgba(200, 245, 100, 0.35);
}

.life-delta-pill.loss {
  background: rgba(255, 107, 117, 0.18);
  color: var(--red);
  border: 1px solid rgba(255, 107, 117, 0.38);
}

@keyframes deltaPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.life-control {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 4px;
  align-items: center;
  margin: 3px 0 4px;
  flex: 1;
  min-width: 0;
}

.life-value {
  font: 800 clamp(22px, 3.7vw, 44px)/1 var(--display);
  letter-spacing: -1.5px;
  margin: 0;
  color: #f7f9fc;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.life-value-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 2px 4px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.life-value-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: #323947;
}

.life-value.is-yugioh {
  font-size: clamp(17px, 2.5vw, 32px);
  letter-spacing: -0.8px;
}

.life-value.low-life {
  color: var(--red);
  text-shadow: 0 0 14px rgba(255, 107, 117, 0.35);
}

/* Sleek Tactical HP Progress Bar */
.hp-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 5px;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #e2ff9e);
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.hp-bar-fill.low {
  background: linear-gradient(90deg, #ff4b57, #ff8f96);
}

.circle-action {
  width: 100%;
  height: 100%;
  min-height: 30px;
  max-height: 52px;
  border-radius: 8px;
  border: 1px solid #303746;
  background: linear-gradient(180deg, #232834 0%, #181c24 100%);
  color: #e6eaf0;
  font: 700 16px var(--sans);
  cursor: pointer;
  touch-action: manipulation;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, border-color 0.15s, color 0.15s;
}

.circle-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.circle-action.minus-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.circle-action:active {
  transform: scale(0.93);
}

.life-quick-steps {
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.quick-step-btn {
  flex: 1;
  min-width: 24px;
  height: 19px;
  padding: 0 3px;
  border-radius: 5px;
  border: 1px solid #282f3c;
  background: linear-gradient(180deg, #1b1f29 0%, #14171f 100%);
  color: #a6b0c0;
  font: 600 8.5px var(--mono);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s, color 0.12s;
}

.quick-step-btn:hover {
  border-color: #495468;
  color: var(--text);
}

.quick-step-btn.step-half {
  color: var(--amber);
  border-color: rgba(255, 202, 100, 0.3);
}

.quick-step-btn:active {
  transform: scale(0.93);
}

.life-foot {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #232833;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #7e8794;
  font: 600 8px var(--mono);
  flex-shrink: 0;
}

/* ==========================================================================
   6. Multi-Target / Multi-Entity Counters
   ========================================================================== */
.multi-counter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 5px;
  align-content: start;
  min-width: 0;
}

.entity-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 9px;
  background: linear-gradient(180deg, #141821 0%, #0e1118 100%);
  border: 1px solid #262c39;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.entity-counter.theme-poison {
  background: linear-gradient(180deg, #231721 0%, #160f16 100%);
  border-color: #442e3e;
}

.entity-counter.theme-poison.danger-threshold {
  border-color: var(--red);
  box-shadow: inset 0 0 12px rgba(255, 107, 117, 0.22);
}

.entity-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.entity-name-input, .entity-label-input {
  width: 100%;
  min-width: 0;
  height: 17px;
  padding: 0 3px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  outline: none;
  text-overflow: ellipsis;
}

.entity-name-input {
  color: #e9eef5;
  font: 700 10.5px var(--sans);
}

.theme-poison .entity-name-input {
  color: #ffb0b9;
}

.entity-label-input {
  color: #848d9b;
  font: 500 8px var(--mono);
  height: 14px;
}

.entity-name-input:focus, .entity-label-input:focus,
.entity-name-input:hover, .entity-label-input:hover {
  border-color: #3c4352;
  background: #14171e;
}

.entity-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.entity-step-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #343b49;
  background: linear-gradient(180deg, #242a36 0%, #191d26 100%);
  color: #e5eaf2;
  font: 700 11px var(--sans);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.08s, border-color 0.12s, color 0.12s;
}

.entity-step-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.entity-step-btn:active {
  transform: scale(0.92);
}

.entity-value {
  font: 800 15px var(--display);
  min-width: 21px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.entity-delete {
  width: 18px;
  height: 23px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #7c8593;
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.entity-delete:hover {
  color: var(--red);
}

.target-presets {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.preset-chip {
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  border: 1px dashed #3a4252;
  background: rgba(20, 24, 32, 0.75);
  color: #aab3c2;
  font: 600 8px var(--mono);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.12s, color 0.12s;
}

.preset-chip:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

/* ==========================================================================
   7. Specialized Cards: Commander, Turn, Dice, Coin, Timer, Conditions
   ========================================================================== */
.commander-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 5px;
}

.commander-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  background: linear-gradient(180deg, #141821 0%, #0e1118 100%);
  border: 1px solid #262c39;
  border-radius: 8px;
}

.commander-row.lethal-cmd {
  border-color: var(--red);
  background: rgba(255, 107, 117, 0.14);
}

.commander-name-input {
  width: 100%;
  min-width: 0;
  height: 18px;
  padding: 1px 3px;
  font: 600 9.5px var(--sans);
  color: #c4ccd8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}

.commander-row strong {
  font: 800 14px var(--mono);
  min-width: 20px;
  text-align: center;
}

.commander-row button {
  width: 23px;
  height: 23px;
  border: 1px solid #353c49;
  background: linear-gradient(180deg, #242a36 0%, #191d26 100%);
  border-radius: 5px;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.compact-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(12, 15, 21, 0.65);
  border: 1px solid #222834;
  border-radius: 8px;
  margin: 2px 0;
  min-width: 0;
}

.stat-big-value {
  font: 800 clamp(20px, 2.8vw, 30px)/1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-big-value.accent-lav {
  color: var(--lav);
  font-size: clamp(16px, 2.2vw, 24px);
}

.stat-big-value.timer-running {
  color: var(--lime);
  text-shadow: 0 0 12px var(--lime-glow);
}

.meter-actions, .roll-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

.meter-actions button, .roll-buttons button {
  flex: 1 1 38px;
  min-width: 0;
  height: 26px;
  border: 1px solid #303746;
  background: linear-gradient(180deg, #222733 0%, #181b24 100%);
  color: #dae1ec;
  border-radius: 6px;
  font: 700 8.5px var(--mono);
  cursor: pointer;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.08s, border-color 0.12s, color 0.12s;
}

.meter-actions button:hover, .roll-buttons button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.meter-actions button:active, .roll-buttons button:active {
  transform: scale(0.94);
}

.conditions-target-list {
  display: grid;
  gap: 5px;
}

.condition-unit {
  padding: 5px 7px;
  background: linear-gradient(180deg, #141821 0%, #0e1118 100%);
  border: 1px solid #262c39;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.condition-unit-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.condition-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cond-pill {
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid #313846;
  background: #1a1e28;
  color: #9da6b5;
  font: 600 8.5px var(--mono);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s;
}

.cond-pill:active { transform: scale(0.93); }
.cond-pill.active-veneno { background: rgba(184, 167, 255, 0.2); border-color: var(--lav); color: #dfd8ff; }
.cond-pill.active-queimadura { background: rgba(255, 107, 117, 0.2); border-color: var(--red); color: #ffc2c6; }
.cond-pill.active-adormecido { background: rgba(112, 192, 255, 0.2); border-color: var(--blue); color: #cbe7ff; }
.cond-pill.active-paralisado { background: rgba(255, 202, 100, 0.2); border-color: var(--amber); color: #ffe7b3; }
.cond-pill.active-confuso { background: rgba(200, 245, 100, 0.2); border-color: var(--lime); color: #e4f9b6; }

.small-copy {
  font-size: 9px;
  color: #848d9a;
  line-height: 1.3;
  margin: 0;
}

.inline-history-feed {
  display: grid;
  gap: 3px;
  font-size: 9.5px;
}

.inline-history-item {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding: 3px 6px;
  background: #11141c;
  border: 1px solid #222733;
  border-radius: 5px;
  color: #b7c0ce;
}

.inline-history-item em {
  font: 600 9px var(--mono);
  color: var(--accent);
  font-style: normal;
}

/* ==========================================================================
   8. Bottom Bar
   ========================================================================== */
.bottombar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  min-height: 0;
  min-width: 0;
}

.ad-slot {
  grid-column: 1 / -1;
  width: min(calc(100% - 48px), 1100px);
  min-height: 144px;
  margin: 0 auto;
  padding: 10px 12px 12px;
  background: #172833;
  border: 1px solid #304754;
  border-radius: 9px;
  color: #bac7cf;
  box-shadow: 0 8px 22px #0003;
  font: 700 9px/1.2 Arial, sans-serif;
  letter-spacing: .1em;
  min-width: 0;
}

.ad-slot[hidden] {
  display: none !important;
}

.ad-label {
  display: block;
  color: inherit;
}

.ad-unit {
  display: block;
  width: 100%;
  height: 100px;
  min-width: 250px;
  margin-top: 9px;
  overflow: hidden;
}

.ad-unit[data-ad-status="unfilled"] {
  height: 0 !important;
  min-height: 0;
  margin-top: 0;
}

.ad-unit[data-ad-status="unfilled"] iframe { display: none !important; }

.footnote {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #77808c;
  font: 500 8px var(--mono);
  white-space: nowrap;
  margin-left: 0;
}

.powered-by {
  flex: 0 0 auto;
  color: #9aa3b2;
  font: 700 9px var(--mono);
  text-decoration: none;
  white-space: nowrap;
  padding: 6px 8px;
  border: 1px solid #252b37;
  border-radius: 7px;
  background: #11141a;
  transition: color 0.15s, border-color 0.15s;
}
.powered-by strong { color: var(--text); }
.powered-by:hover { color: var(--accent); border-color: var(--accent); }
.powered-by:hover strong { color: var(--accent); }

/* ==========================================================================
   9. Modals
   ========================================================================== */
.modal {
  width: min(680px, calc(100vw - 16px));
  max-height: min(90dvh, 760px);
  padding: 0;
  border: 1px solid #363d4a;
  border-radius: 15px;
  background: linear-gradient(165deg, #191d27 0%, #12151c 100%);
  color: var(--text);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.modal::backdrop {
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(5px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 11px;
  border-bottom: 1px solid #2a2f3a;
  gap: 8px;
}

.modal-head small {
  font: 700 8.5px var(--mono);
  letter-spacing: 1.2px;
  color: var(--lime);
}

.modal-head h2 {
  font: 800 17px var(--display);
  margin: 3px 0 2px;
}

.modal-head p {
  font-size: 10.5px;
  color: #969fab;
  margin: 0;
}

.modal-content {
  padding: 13px 16px 16px;
  max-height: calc(90dvh - 80px);
  overflow-y: auto;
}

.coffee-nudge-modal { width: min(440px, calc(100vw - 24px)); }
.coffee-nudge-content { padding: 24px; text-align: center; }
.coffee-nudge-icon { display: block; font-size: 32px; margin-bottom: 8px; }
.coffee-nudge-content h2 { margin: 0 0 9px; font: 800 19px var(--display); }
.coffee-nudge-content p { margin: 0; color: #aab2bf; font-size: 12px; line-height: 1.55; }
.coffee-nudge-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.coffee-nudge-actions .action-btn { min-height: 32px; }

.custom-creator-box {
  padding: 10px;
  background: #11141b;
  border: 1px solid #2a3140;
  border-radius: 10px;
  margin-bottom: 12px;
}

.creator-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.creator-header strong {
  font: 700 11.5px var(--sans);
  color: var(--lime);
}

.creator-header small {
  font-size: 9.5px;
  color: #87909e;
}

.creator-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.4fr auto;
  gap: 6px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
  font: 700 9px var(--mono);
  color: #97a0ae;
}

.grid-cols-picker {
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 9px;
  background: #1b1f28;
  border: 1px solid #2c3342;
  border-radius: 8px;
  min-width: 0;
}

.custom-item.is-active {
  border-color: #4b5d38;
  background: #192119;
}

.custom-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.custom-item-left input {
  accent-color: var(--lime);
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
}

.custom-item-left span {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-item-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.span-select {
  padding: 2px 4px;
  font: 600 9px var(--mono);
  height: 22px;
  border-radius: 5px;
  background: #14171e;
  border: 1px solid #343b49;
}

.delete-custom-tool {
  width: 21px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid #453137;
  background: #251a1e;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  display: grid;
  place-items: center;
  padding: 0;
}

.saved-layouts-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #292e39;
}

.layout-row {
  display: flex;
  gap: 7px;
  align-items: flex-end;
}

.layout-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.layout-input-wrap label {
  font: 700 8px var(--mono);
  color: #939ca9;
}

.save-layout {
  height: 32px;
  background: linear-gradient(180deg, #d7fc82 0%, #b7e84f 100%);
  border: 0;
  border-radius: 7px;
  padding: 0 11px;
  color: #161d0b;
  font: 700 11px var(--sans);
  cursor: pointer;
  white-space: nowrap;
}

.saved-layouts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.saved-layout-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: #1f242e;
  border: 1px solid #343c4b;
  border-radius: 6px;
  font-size: 10.5px;
}

.saved-layout-pill button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.modal-note {
  font-size: 10px;
  color: #8b94a2;
  line-height: 1.4;
  margin: 10px 0 0;
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 4px;
  gap: 6px;
}

.history-export-group {
  display: flex;
  gap: 5px;
}

.export-history {
  border: 1px solid #465339;
  border-radius: 6px;
  background: #20271b;
  color: var(--lime);
  padding: 5px 9px;
  font: 600 10px var(--sans);
  cursor: pointer;
}

.history-list {
  padding: 6px 16px 16px;
  max-height: 55dvh;
  overflow-y: auto;
}

.history-entry {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  padding: 8px 6px;
  border: 0;
  border-bottom: 1px solid #282c35;
  background: transparent;
  color: var(--text);
  font-size: 10.5px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.history-entry.history-current {
  background: #22291e;
  box-shadow: inset 3px 0 var(--lime);
}

.history-entry time {
  font: 600 9px var(--mono);
  color: #828a96;
}

.history-entry em {
  font: 600 9.5px var(--mono);
  font-style: normal;
  color: var(--lime);
}

.history-empty {
  padding: 22px 4px;
  text-align: center;
  color: #8e96a2;
  font-size: 11px;
}

.settings-grid {
  display: grid;
  gap: 8px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: #1b1f28;
  border: 1px solid #2b313e;
  border-radius: 9px;
}

.setting-row strong {
  display: block;
  font-size: 11.5px;
}

.setting-row small {
  color: #8a93a0;
  font-size: 10px;
}

.setting-input {
  width: 80px;
  text-align: right;
}

.offline-box {
  margin-top: 12px;
  padding: 10px;
  background: #12151c;
  border: 1px solid #2d3442;
  border-radius: 9px;
}

.offline-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.offline-box-head strong {
  display: block;
  font-size: 11.5px;
  color: var(--lime);
}

.offline-box-head small {
  font-size: 9.5px;
  color: #8e97a4;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.danger-button {
  border: 1px solid #573339;
  border-radius: 6px;
  background: #29181b;
  color: var(--red);
  padding: 5px 9px;
  font: 600 10px var(--sans);
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  padding: 7px 14px;
  background: #232833;
  border: 1px solid #485060;
  border-radius: 8px;
  color: #f3f5f8;
  font: 600 11px var(--sans);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: 0.2s ease;
  z-index: 50;
  max-width: calc(100vw - 24px);
  text-align: center;
}

.icon-button.help-button {
  font: 800 13px var(--mono);
  color: var(--accent);
  border-color: rgba(255, 255, 255, 0.14);
}

.icon-button.pwa-top-btn {
  color: var(--lime);
  border-color: rgba(200, 245, 100, 0.45);
  background: linear-gradient(180deg, rgba(200, 245, 100, 0.18) 0%, rgba(200, 245, 100, 0.06) 100%);
}

.icon-button.coffee-top-btn {
  color: var(--amber);
  border-color: rgba(255, 202, 100, 0.35);
  background: linear-gradient(180deg, rgba(255, 202, 100, 0.16) 0%, rgba(255, 202, 100, 0.05) 100%);
}

.icon-button.coffee-top-btn:hover {
  border-color: var(--amber);
  color: #ffe3a8;
  background: linear-gradient(180deg, rgba(255, 202, 100, 0.25) 0%, rgba(255, 202, 100, 0.1) 100%);
}

.coffee-foot-pill {
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 202, 100, 0.35);
  background: linear-gradient(180deg, rgba(255, 202, 100, 0.14) 0%, rgba(255, 202, 100, 0.04) 100%);
  color: var(--amber);
  font: 700 9px var(--sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.1s, border-color 0.15s;
}

.coffee-foot-pill:hover {
  border-color: var(--amber);
  color: #ffe6b0;
}

.coffee-foot-pill:active {
  transform: scale(0.95);
}

/* ==========================================================================
   9.35 Coffee / Support the Dev Modal (Pix + Ko-fi + Inter Global)
   ========================================================================== */
.coffee-modal {
  width: min(560px, calc(100vw - 16px));
}

.coffee-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coffee-card {
  padding: 12px 13px;
  border-radius: 11px;
  background: linear-gradient(180deg, #161a24 0%, #10131b 100%);
  border: 1px solid #29303f;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.coffee-card.kofi-channel {
  border-color: rgba(255, 202, 100, 0.38);
  background:
    radial-gradient(110% 120% at 0% 0%, rgba(255, 202, 100, 0.1) 0%, transparent 60%),
    linear-gradient(180deg, #181b24 0%, #11141c 100%);
}

.coffee-card.pix-channel {
  border-color: rgba(94, 242, 214, 0.35);
  background:
    radial-gradient(110% 120% at 0% 0%, rgba(94, 242, 214, 0.09) 0%, transparent 60%),
    linear-gradient(180deg, #151c22 0%, #10141a 100%);
}

.coffee-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.coffee-channel-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--amber);
  flex-shrink: 0;
}

.pix-channel .coffee-channel-icon {
  color: #5ef2d6;
}

.coffee-card-head strong {
  display: block;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 2px;
}

.coffee-card-head small {
  display: block;
  font-size: 10.5px;
  color: #949eae;
  line-height: 1.35;
}

.coffee-card-actions {
  display: flex;
}

.coffee-primary-link {
  width: 100%;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 12px;
  background: linear-gradient(180deg, #ffd778 0%, #f5b342 100%);
  color: #1c1202;
  border-radius: 8px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 14px rgba(245, 179, 66, 0.22);
}

.coffee-primary-link:hover {
  background: linear-gradient(180deg, #ffe299 0%, #ffc054 100%);
}

.coffee-key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0d1016;
  border: 1px solid #242b38;
  flex-wrap: wrap;
}

.coffee-key-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.coffee-key-meta span {
  font: 700 8.5px var(--mono);
  color: #5ef2d6;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.coffee-key-meta code {
  font: 700 11.5px var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pix-qr-layout {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pix-qr-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1.5px solid rgba(94, 242, 214, 0.45);
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.15s;
}

.pix-qr-button:hover {
  transform: scale(1.03);
  box-shadow: 0 0 18px rgba(94, 242, 214, 0.35);
}

.pix-qr-button:active {
  transform: scale(0.96);
}

.pix-qr-img {
  width: 96px;
  height: 96px;
  display: block;
  border-radius: 4px;
}

.pix-qr-hint {
  font: 800 8px var(--sans);
  color: #0b1917;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pix-details-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.pix-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pix-action-buttons button {
  flex: 1;
  min-width: 120px;
}

@media (max-width: 480px) {
  .pix-qr-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .pix-qr-button {
    align-self: center;
  }
}

.global-bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.global-bank-item {
  padding: 7px 9px;
  border-radius: 8px;
  background: #0d1016;
  border: 1px solid #232a36;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.global-bank-item span {
  font: 700 8px var(--mono);
  color: var(--muted);
  letter-spacing: 0.7px;
}

.global-bank-item strong,
.global-bank-item code {
  font: 700 11px var(--mono);
  color: var(--text);
}

.global-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.coffee-thanks {
  text-align: center;
  font: 700 11px var(--sans);
  color: var(--amber);
  margin: 4px 0 0;
}

.icon-button.pwa-top-btn[hidden] {
  display: none !important;
}

.pwa-specs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.pwa-spec-item {
  padding: 7px 9px;
  border-radius: 7px;
  background: #171b24;
  border: 1px solid #262c3a;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-spec-item span {
  font: 700 8px var(--mono);
  color: var(--muted);
  letter-spacing: 0.7px;
}

.pwa-spec-item strong {
  font: 700 11px var(--sans);
  color: var(--text);
}

/* ==========================================================================
   9.4 Onboarding Tutorial Modal
   ========================================================================== */
.tutorial-modal {
  width: min(540px, calc(100vw - 16px));
}

.tutorial-content {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.tutorial-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background:
    radial-gradient(110% 120% at 0% 0%, var(--accent-dim) 0%, transparent 65%),
    linear-gradient(180deg, #151923 0%, #10131b 100%);
  border: 1px solid #2a3140;
}

.tutorial-icon-ring {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 800 22px var(--display);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-dim), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tutorial-step-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  flex: 1;
}

.tutorial-step-badge {
  font: 800 9.5px var(--mono);
  letter-spacing: 1.1px;
  color: var(--accent);
  text-transform: uppercase;
}

.tutorial-dots {
  display: flex;
  gap: 6px;
}

.tutorial-dot {
  width: 22px;
  height: 6px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: #2b3242;
  cursor: pointer;
  transition: width 0.2s, background 0.2s;
}

.tutorial-dot.active {
  width: 34px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.tutorial-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: #d5dce8;
}

.tutorial-highlights {
  display: grid;
  gap: 7px;
}

.tutorial-highlight-card {
  padding: 9px 11px;
  border-radius: 9px;
  background: #12151d;
  border: 1px solid #262c39;
  font-size: 11.5px;
  line-height: 1.45;
  color: #e4eaf3;
  box-shadow: inset 3px 0 0 var(--accent);
}

.tutorial-quick-backup {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(200, 245, 100, 0.06);
  border: 1px dashed rgba(200, 245, 100, 0.35);
}

.tutorial-quick-backup[hidden] {
  display: none !important;
}

.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #262c38;
}

.tutorial-footer-right {
  display: flex;
  gap: 6px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   9.5 Fullscreen 3D Coin Flip & Dice Roll Animation Overlay
   ========================================================================== */
.roll-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  perspective: 1100px;
  animation: overlayFadeIn 0.18s ease-out both;
}

.roll-overlay[hidden] {
  display: none !important;
}

.roll-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(22, 28, 38, 0.9) 0%, rgba(5, 7, 11, 0.95) 75%);
  backdrop-filter: blur(8px);
}

.roll-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(380px, 100%);
  padding: 26px 22px 22px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(28, 33, 44, 0.96), rgba(14, 17, 23, 0.98));
  border: 1px solid rgba(200, 245, 100, 0.28);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  pointer-events: auto;
}

.roll-stage.landed {
  border-color: var(--lime);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.9), 0 0 42px rgba(200, 245, 100, 0.2);
}

.roll-badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(200, 245, 100, 0.12);
  border: 1px solid rgba(200, 245, 100, 0.35);
  color: var(--lime);
  font: 800 10px var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.roll-3d-viewport {
  width: 170px;
  height: 170px;
  display: grid;
  place-items: center;
  perspective: 900px;
  position: relative;
}

.roll-3d-viewport::after {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid var(--lime);
  opacity: 0;
  pointer-events: none;
}

.roll-stage.landed .roll-3d-viewport::after {
  animation: shockwavePulse 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.coin-3d {
  width: 138px;
  height: 138px;
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.coin-3d.spin-cara {
  animation:
    coinFlipCara 4s cubic-bezier(0.12, 0.8, 0.25, 1) forwards,
    rollArc 4s ease-out forwards;
}

.coin-3d.spin-coroa {
  animation:
    coinFlipCoroa 4s cubic-bezier(0.12, 0.8, 0.25, 1) forwards,
    rollArc 4s ease-out forwards;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 5px solid #e6c665;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55), 0 12px 30px rgba(0, 0, 0, 0.6);
}

.coin-face::before {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 238, 173, 0.55);
}

.coin-face-cara {
  background: radial-gradient(circle at 32% 28%, #ffe999 0%, #d4a338 58%, #8f6814 100%);
  color: #231802;
}

.coin-face-coroa {
  background: radial-gradient(circle at 32% 28%, #e4ecff 0%, #8e9ec2 58%, #4d5975 100%);
  border-color: #c6d3f0;
  color: #101624;
  transform: rotateY(180deg);
}

.coin-symbol {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 3px;
  filter: drop-shadow(0 2px 3px rgba(255, 255, 255, 0.35));
}

.coin-text {
  font: 900 16px/1 var(--display);
  letter-spacing: 1.5px;
}

.die-3d {
  width: 136px;
  height: 136px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #272d3d 0%, #151822 100%);
  border: 2.5px solid var(--lav);
  border-radius: 26px;
  box-shadow: inset 0 0 24px rgba(184, 167, 255, 0.22), 0 16px 38px rgba(0, 0, 0, 0.68);
  transform-style: preserve-3d;
  will-change: transform;
}

.die-3d.shape-d4 {
  clip-path: polygon(50% 4%, 96% 90%, 4% 90%);
  border-radius: 12px;
  padding-top: 24px;
}

.die-3d.shape-d8,
.die-3d.shape-d10 {
  clip-path: polygon(50% 2%, 96% 50%, 50% 98%, 4% 50%);
  border-radius: 14px;
}

.die-3d.shape-d12,
.die-3d.shape-d20 {
  clip-path: polygon(50% 2%, 93% 25%, 93% 75%, 50% 98%, 7% 75%, 7% 25%);
  border-radius: 16px;
}

.die-3d.rolling {
  animation:
    dieTumble3D 4s cubic-bezier(0.12, 0.8, 0.25, 1) forwards,
    rollArc 4s ease-out forwards;
}

.roll-stage.landed .die-3d {
  border-color: var(--lime);
  box-shadow: inset 0 0 28px rgba(200, 245, 100, 0.28), 0 0 32px rgba(200, 245, 100, 0.25);
}

.die-type-tag {
  font: 700 10px var(--mono);
  letter-spacing: 1.4px;
  color: #a3adbf;
  margin-bottom: 2px;
}

.die-number {
  font: 900 clamp(38px, 9vw, 54px)/1 var(--display);
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.roll-stage.landed .die-number {
  color: var(--lime);
  animation: numberPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.roll-final-title {
  font: 900 clamp(24px, 5vw, 32px)/1.1 var(--display);
  color: var(--text);
  letter-spacing: -0.6px;
  min-height: 34px;
}

.roll-stage.landed .roll-final-title {
  color: var(--lime);
}

.roll-final-sub {
  font: 500 11px var(--sans);
  color: var(--muted);
}

.roll-overlay-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}

.roll-overlay-actions .action-btn {
  height: 36px;
  padding: 0 16px;
  font-size: 12px;
}

@keyframes overlayFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes coinFlipCara {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(3960deg) rotateY(2880deg) rotateZ(360deg); }
}

@keyframes coinFlipCoroa {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(3960deg) rotateY(3060deg) rotateZ(360deg); }
}

@keyframes dieTumble3D {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(3240deg) rotateY(-2880deg) rotateZ(1800deg); }
}

@keyframes rollArc {
  0% { scale: 0.78; }
  25% { scale: 1.14; }
  100% { scale: 1; }
}

@keyframes shockwavePulse {
  0% { transform: scale(0.8); opacity: 0.85; }
  100% { transform: scale(1.65); opacity: 0; }
}

@keyframes numberPop {
  0% { transform: scale(0.65); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   10. Mobile & Narrow Viewport Optimizations (0px overflow guaranteed)
   ========================================================================== */
@media (max-width: 820px) {
  .creator-form {
    grid-template-columns: 1fr 1fr;
  }
  .creator-form button {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 5px 6px;
    gap: 5px;
  }

  .topbar {
    gap: 5px;
    min-height: 30px;
  }

  .brand small,
  .offline-badge {
    display: none;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
    max-height: 30px;
    object-fit: contain;
  }

  .brand-title {
    font-size: 13px;
  }

  .session-pill {
    padding: 3px 8px;
    font-size: 8.5px;
    gap: 4px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .lang-top-wrap {
    width: 30px;
    height: 28px;
  }

  .lang-badge-label {
    font-size: 9.5px;
  }

  .control-bar {
    padding: 5px;
    gap: 5px;
  }

  .picker-group {
    display: flex;
    gap: 4px;
    width: 100%;
  }

  .picker-field {
    padding: 1px 5px;
    flex: 1 1 0;
  }

  .picker-field.picker-players {
    flex: 0 1 98px;
  }

  .picker-field label {
    display: none;
  }

  .picker-field select {
    font-size: 11px;
    padding: 3px 0;
  }

  .action-group {
    width: 100%;
    display: grid;
    grid-template-columns: 32px 32px 1fr 34px auto;
    gap: 4px;
  }

  .action-btn {
    height: 27px;
    padding: 0 6px;
    font-size: 10.5px;
  }

  .btn-label,
  .btn-label-full {
    display: none;
  }

  .btn-label-short {
    display: inline;
  }

  .board {
    gap: 5px;
  }

  .tool-card {
    padding: 6px 8px;
    border-radius: 11px;
  }

  .tool-top {
    margin-bottom: 3px;
  }

  .tool-label {
    font-size: 8.5px;
  }

  .tool-card.col-span-1 .life-players.players-2 {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .life-player {
    padding: 5px 6px;
  }

  .life-control {
    grid-template-columns: 29px minmax(0, 1fr) 29px;
    margin: 2px 0 3px;
  }

  .life-value {
    font-size: clamp(20px, 6vw, 30px);
  }

  .circle-action {
    min-height: 26px;
    font-size: 14px;
  }

  .quick-step-btn {
    height: 17px;
    font-size: 8px;
    min-width: 20px;
  }

  .life-foot,
  .target-presets {
    display: none;
  }

  .custom-grid {
    grid-template-columns: 1fr;
  }

  .bottombar { min-height: 0; gap: 6px; }

  .footnote {
    display: none;
  }

  .ad-slot {
    width: calc(100% - 32px);
    min-height: 144px;
    padding: 8px;
  }

  .ad-unit { min-width: 0; height: 100px; }
  .powered-by { font-size: 7.5px; padding: 5px; }
}
