html,
body {
  overscroll-behavior: none;
}

body.lc-game-active {
  overflow: hidden;
}

#life-counter-page {
  --lc-bg: var(--bg);
  --lc-bg-2: var(--bg-card);
  --lc-surface: var(--bg-card);
  --lc-elevated: var(--bg-raised);
  --lc-elevated-2: var(--bg-overlay);
  --lc-border: var(--border);
  --lc-border-strong: var(--border-glow);
  --lc-gold: var(--gold);
  --lc-gold-soft: rgba(201, 168, 76, 0.18);
  --lc-text: var(--text);
  --lc-text-muted: var(--text-muted);
  --lc-text-dim: var(--text-dim);
  --lc-shadow: var(--shadow);
  --lc-space-1: 0.25rem;
  --lc-space-2: 0.5rem;
  --lc-space-3: 0.75rem;
  --lc-space-4: 1rem;
  --lc-space-5: 1.5rem;
  --lc-space-6: 2rem;
  --lc-radius: var(--radius, 6px);
  --lc-radius-lg: var(--radius-lg, 12px);
  --lc-safe-top: env(safe-area-inset-top, 0px);
  --lc-safe-bottom: env(safe-area-inset-bottom, 0px);
  --lc-ad-strip: 0px;
  --lc-ad-height: calc(var(--lc-ad-strip) + var(--lc-safe-bottom));
  --lc-toolbar-height: 76px;
  --lc-sidebar-width: 220px;
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  overflow: visible;
  background: transparent;
  color: var(--lc-text);
  isolation: isolate;
}

#life-counter-page *,
#life-counter-page *::before,
#life-counter-page *::after {
  box-sizing: border-box;
}

.lc-screen {
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    visibility 0.3s ease;
}

.lc-screen--setup {
  position: relative;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

#life-counter-page[data-screen="game"] .lc-screen--setup {
  display: none;
}

.lc-screen--game {
  position: fixed;
  inset: 0;
  z-index: 350;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(18px);
}

#life-counter-page[data-screen="game"] .lc-screen--game {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.lc-screen__scroll {
  padding: 0;
}

.lc-setup-shell {
  min-height: auto;
  width: 100%;
}

.lc-setup-panel {
  width: 100%;
  display: grid;
  gap: 0.9rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.lc-page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.lc-page-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 108px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent);
}

.lc-page-heading h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0.06em;
}

.lc-page-header .page-subtitle {
  margin-top: 0.35rem;
  max-width: 42rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.lc-panel-head {
  display: grid;
  gap: 0.45rem;
}

.lc-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.lc-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.4vw, 1.65rem);
  line-height: 1.12;
  letter-spacing: 0.04em;
}

.lc-subtitle {
  margin: 0;
  color: var(--lc-text-muted);
  font-size: 0.9rem;
  max-width: 58ch;
}

.lc-setup-grid {
  display: grid;
  gap: 0.9rem;
}

.lc-setup-section {
  padding: 0;
  overflow: hidden;
}

.lc-setup-section-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lc-setup-section-copy {
  display: grid;
  gap: 0.12rem;
}

.lc-setup-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.66rem;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lc-setup-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.55;
}

.lc-setup-section-body {
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem 1rem 1rem;
}

.lc-section-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.lc-pill-row,
.lc-chip-row,
.lc-layout-grid,
.lc-toolbar-cluster,
.lc-counter-row-actions,
.lc-dice-option-row,
.lc-qty-row,
.lc-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.lc-chip,
.lc-life-pad-mode,
.lc-toolbar-btn,
.lc-counter-tab,
.lc-dice-option,
.lc-qty-btn,
.lc-life-pad-key,
.lc-sheet-close {
  min-height: 38px;
  border-radius: var(--lc-radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg,
      rgba(40, 48, 68, 0.98) 0%,
      rgba(24, 30, 45, 0.98) 100%);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.lc-chip:hover,
.lc-life-pad-mode:hover,
.lc-toolbar-btn:hover,
.lc-counter-tab:hover,
.lc-dice-option:hover,
.lc-qty-btn:hover,
.lc-life-pad-key:hover,
.lc-sheet-close:hover {
  transform: translateY(-1px);
  border-color: var(--border-glow);
  color: var(--text);
}

[data-theme="light"] .lc-chip,
[data-theme="light"] .lc-life-pad-mode,
[data-theme="light"] .lc-toolbar-btn,
[data-theme="light"] .lc-counter-tab,
[data-theme="light"] .lc-dice-option,
[data-theme="light"] .lc-qty-btn,
[data-theme="light"] .lc-life-pad-key,
[data-theme="light"] .lc-sheet-close {
  background: linear-gradient(180deg, #fbf6ec 0%, #efe4d3 100%);
  box-shadow: none;
  color: #4f3c1f;
}

.lc-pill.is-active,
.lc-chip.is-active,
.lc-layout-button.is-active,
.lc-toolbar-btn.is-active,
.lc-counter-tab.is-active,
.lc-dice-option.is-active,
.lc-qty-btn.is-active {
  background: rgba(201, 168, 76, 0.18);
  border-color: var(--gold-dim);
  color: var(--gold);
  box-shadow: none;
}

[data-theme="light"] .lc-pill.is-active,
[data-theme="light"] .lc-chip.is-active,
[data-theme="light"] .lc-layout-button.is-active,
[data-theme="light"] .lc-toolbar-btn.is-active,
[data-theme="light"] .lc-counter-tab.is-active,
[data-theme="light"] .lc-dice-option.is-active,
[data-theme="light"] .lc-qty-btn.is-active {
  background: #5f4412;
  border-color: #5f4412;
  color: #fff;
}

.lc-screen--setup .lc-pill--text {
  font-size: 0.5rem;
  letter-spacing: 0.035em;
}

.lc-chip-row--setup-life {
  align-items: center;
  gap: 0.45rem;
}

.lc-chip-row--setup-life .lc-stepper {
  flex: 0 1 6.55rem;
  width: 6.55rem;
}

.lc-chip-row--setup-life .lc-inline-edit-row {
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.lc-stepper {
  display: grid;
  grid-template-columns: minmax(1.5rem, 1.7rem) minmax(0, 1fr) minmax(1.5rem, 1.7rem);
  gap: 0.24rem;
  align-items: stretch;
}

.lc-stepper-btn {
  min-height: 1.3rem;
  min-width: 1.5rem;
  padding: 0.06rem 0.26rem;
  padding-inline: 0;
  font-family: var(--font-body);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

.lc-stepper-value,
.lc-inline-input,
.lc-threshold-input,
.lc-turn-input,
.lc-counter-name-input,
.lc-counter-threshold-input {
  width: 100%;
  min-height: 38px;
  border-radius: var(--lc-radius);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  text-align: center;
  padding: 0.55rem 0.85rem;
}

.lc-stepper-value {
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  min-height: 1.3rem;
  padding: 0.06rem 0.26rem;
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  cursor: pointer;
}

.lc-inline-input,
.lc-threshold-input,
.lc-turn-input,
.lc-counter-name-input,
.lc-counter-threshold-input {
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
}

.lc-inline-input:focus,
.lc-threshold-input:focus,
.lc-turn-input:focus,
.lc-counter-name-input:focus,
.lc-counter-threshold-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
}

.lc-inline-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.lc-screen--setup .lc-inline-input {
  min-height: 1.3rem;
  padding: 0.06rem 0.26rem;
  font-family: var(--font-body);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

.lc-inline-btn,
.lc-link-btn,
.lc-sheet-close {
  padding: 0.34rem 0.82rem;
}

.lc-screen--setup .lc-inline-btn,
.lc-screen--setup .lc-inline-edit-row .btn {
  min-height: 1.3rem;
  padding: 0.06rem 0.26rem;
  font-size: 0.5rem;
  letter-spacing: 0.035em;
  line-height: 1;
}

.lc-link-btn {
  background: transparent;
  box-shadow: none;
}

.lc-player-config-list {
  display: grid;
  gap: 0.75rem;
}

.lc-player-row {
  display: grid;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-raised);
}

.lc-player-row-head,
.lc-player-row-tail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.lc-player-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: #f9f4eb;
  background: var(--badge-color, #2a3a4a);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.lc-player-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.lc-player-meta-copy {
  min-width: 0;
}

.lc-player-meta-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lc-player-meta-copy span {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.5;
}

.lc-player-name-input {
  display: inline-block;
  min-width: 4ch;
  max-width: 100%;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--lc-radius);
  padding: 0.18rem 0.3rem;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lc-player-name-input:hover {
  border-color: var(--border);
}

.lc-player-name-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.1);
  background: var(--bg-raised);
}

.lc-player-name-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-dim);
}

.lc-player-color-group {
  margin: 0;
  min-width: 0;
  align-self: center;
}

.lc-player-color-group label {
  margin-bottom: 0.45rem;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

.lc-player-color-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.lc-player-color-presets {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.lc-player-color-option {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch-color, #2a3a4a);
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.lc-player-color-option.is-active {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px rgba(201, 168, 76, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

[data-theme="light"] .lc-player-color-option.is-active {
  border-color: #5f4412;
  box-shadow:
    0 0 0 1px rgba(95, 68, 18, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.lc-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 0.55rem;
}

.lc-layout-button {
  min-height: 0;
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.32rem;
  text-align: left;
  white-space: normal;
  align-items: start;
}

.lc-layout-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lc-layout-meta {
  display: block;
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.45;
}

.lc-layout-icon {
  width: 100%;
  border-radius: var(--lc-radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
  padding: 0.32rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lc-layout-icon svg {
  width: auto;
  height: 36px;
  display: block;
}

.lc-layout-toolbar .lc-layout-icon svg {
  height: 28px;
}

.lc-layout-toolbar {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.lc-layout-toolbar .lc-layout-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.45rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(40, 48, 68, 0.98) 0%, rgba(24, 30, 45, 0.98) 100%);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

[data-theme="light"] .lc-layout-toolbar .lc-layout-button {
  background: linear-gradient(180deg, #fbf6ec 0%, #efe4d3 100%);
  border-color: rgba(138, 104, 32, 0.18);
  color: #4f3c1f;
}

.lc-layout-toolbar .lc-layout-button.is-active {
  background: rgba(201, 168, 76, 0.18);
  border-color: var(--gold-dim);
  color: var(--gold);
}

[data-theme="light"] .lc-layout-toolbar .lc-layout-button.is-active {
  background: #5f4412;
  border-color: #5f4412;
  color: #fff;
}

.lc-layout-toolbar .lc-layout-label,
.lc-layout-toolbar .lc-layout-meta {
  display: none;
}

.lc-layout-toolbar .lc-layout-icon {
  min-height: 32px;
  padding: 0.26rem;
}

.lc-start-btn {
  width: 100%;
  margin-top: 0.1rem;
}

.lc-game-root {
  height: 100%;
}

.lc-game-shell {
  height: 100%;
  display: flex;
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(201, 162, 39, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(26, 90, 90, 0.28), transparent 30%),
    linear-gradient(160deg, #090909 0%, #111111 55%, #171717 100%);
}

[data-theme="light"] .lc-game-shell {
  background:
    radial-gradient(circle at top left, rgba(138, 104, 32, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(61, 143, 130, 0.16), transparent 32%),
    linear-gradient(160deg, #dad1c3 0%, #e8dfd0 50%, #d6ccbc 100%);
}

.lc-game-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lc-play-area {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.85rem;
  overflow: hidden;
}

.lc-player-grid {
  height: 100%;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(var(--lc-cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--lc-rows, 1), minmax(0, 1fr));
}

.lc-play-area:has(.lc-player-grid[data-layout="stack"]) {
  overflow-y: auto;
}

.lc-player-grid[data-layout="stack"] {
  height: auto;
  min-height: 100%;
  grid-template-rows: none;
}

.lc-player-card {
  position: relative;
  overflow: hidden;
  min-height: 140px;
  border-radius: calc(var(--lc-radius-lg) + 4px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 36%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.28)),
    var(--player-color, #2a3a4a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition:
    opacity 0.24s ease,
    filter 0.24s ease,
    transform 0.24s ease;
  user-select: none;
}

.lc-player-card-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(0.7rem, 2vw, 1rem);
  gap: 0.55rem;
}

.lc-player-card[data-rotated="true"] .lc-player-card-inner {
  transform: rotate(180deg);
}

.lc-player-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.lc-player-name {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
}

.lc-player-name strong {
  font-weight: 600;
}

.lc-player-note {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.76rem;
}

.lc-life-display {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: center;
  cursor: pointer;
}

.lc-life-display:disabled,
.lc-life-btn:disabled,
.lc-chip:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.lc-player-card .lc-life-btn {
  min-height: 38px;
  border-radius: var(--lc-radius);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lc-player-card .lc-life-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.44);
}

.lc-life-value {
  font-family: "Teko", var(--font-display), serif;
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  line-height: 0.92;
  letter-spacing: 0.04em;
  text-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  color: #fff;
}

.lc-life-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.lc-life-side {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
}

.lc-player-card .lc-life-btn {
  min-height: 26px;
  min-width: 46px;
}

.lc-chip-bar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
}

.lc-chip {
  padding: 0.45rem 0.62rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.lc-chip-value {
  font-family: "Teko", var(--font-display), serif;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: 0.04em;
}

.lc-card-panel-value {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: var(--lc-radius);
  border: 1px solid var(--lc-border);
  background: var(--lc-elevated);
  text-align: center;
  font-family: "Teko", var(--font-display), serif;
  font-size: 1.75rem;
  letter-spacing: 0.05em;
}

.lc-life-pad-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 76px;
  border-radius: var(--lc-radius);
  border: 1px solid var(--lc-border-strong);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  padding: 0.5rem 0.75rem;
}

.lc-life-pad-preview-result {
  font-family: "Teko", var(--font-display), serif;
  font-size: 2.8rem;
  line-height: 1;
  letter-spacing: 0.04em;
}

.lc-life-pad-preview-current {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lc-text-muted);
}

.lc-life-pad-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.lc-life-pad-mode {
  min-height: 40px;
  font-size: 0.75rem;
}

.lc-life-pad-mode.is-active {
  background: rgba(201, 168, 76, 0.18);
  border-color: var(--lc-gold);
  color: var(--lc-gold);
}

[data-theme="light"] .lc-life-pad-mode.is-active {
  background: #5f4412;
  border-color: #5f4412;
  color: #fff;
}

.lc-counter-note,
.lc-history-empty,
.lc-sheet-note {
  margin: 0;
  color: var(--lc-text-dim);
  font-size: 0.82rem;
}

.lc-counter-note--warning {
  color: var(--lc-accent);
  font-weight: 600;
}

.lc-counter-max {
  font-size: 0.65em;
  opacity: 0.55;
  margin-left: 0.1em;
}

.lc-counter-row-actions {
  align-items: center;
}

.lc-life-pad {
  --modal-max-width: 320px;
  position: relative;
  gap: 0.75rem;
}

.lc-life-pad .modal-header {
  margin-bottom: 0;
  border-left: 4px solid var(--lc-player-color, var(--lc-gold));
  padding-left: 0.65rem;
}

.lc-life-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.lc-life-pad-key {
  min-height: 54px;
  font-family: "Teko", var(--font-display), serif;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
}

.lc-toolbar {
  position: relative;
  flex: 0 0 var(--lc-toolbar-height);
  min-height: var(--lc-toolbar-height);
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.7rem 0.85rem calc(0.7rem + (var(--lc-safe-bottom) * 0.15));
  border-top: 1px solid var(--lc-border);
  background: rgba(12, 12, 12, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

[data-theme="light"] .lc-toolbar {
  background: rgba(246, 241, 232, 0.9);
}

.lc-toolbar-cluster {
  align-items: center;
}

.lc-toolbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.lc-toolbar-btn {
  padding: 0.34rem 0.82rem;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lc-turn-btn {
  min-height: 40px;
  width: min(100%, 180px);
  justify-self: center;
  border-radius: var(--lc-radius);
  border: 1px solid var(--lc-border-strong);
  background: rgba(201, 162, 39, 0.12);
  color: inherit;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.lc-layout-tray {
  position: absolute;
  right: 0.85rem;
  bottom: calc(100% + 0.45rem);
  z-index: 10;
  max-width: min(92vw, 280px);
  padding: 0.6rem;
  border-radius: var(--lc-radius-lg);
  border: 1px solid var(--lc-border);
  background: rgba(16, 16, 16, 0.92);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

[data-theme="light"] .lc-layout-tray {
  background: rgba(248, 243, 235, 0.98);
}

.lc-sidebar {
  display: none;
  width: var(--lc-sidebar-width);
  flex: 0 0 var(--lc-sidebar-width);
  border-left: 1px solid var(--lc-border);
  background: rgba(12, 12, 12, 0.88);
  padding: 0.85rem 0.85rem 0.95rem;
  min-height: 0;
  gap: 0.85rem;
  flex-direction: column;
}

[data-theme="light"] .lc-sidebar {
  background: rgba(246, 241, 232, 0.9);
}

.lc-sidebar-section {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: var(--lc-radius-lg);
  border: 1px solid var(--lc-border);
  background: rgba(255, 255, 255, 0.03);
}

.lc-sidebar-section.is-highlighted {
  border-color: var(--lc-border-strong);
  background: var(--lc-gold-soft);
}

[data-theme="light"] .lc-sidebar-section {
  background: rgba(255, 255, 255, 0.34);
}

.lc-sidebar-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lc-counter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.lc-counter-tab {
  padding: 0.4rem 0.72rem;
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lc-counter-tab:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.lc-manager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.lc-threshold-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.lc-threshold-label {
  font-size: 0.78rem;
  color: var(--lc-text-muted);
  white-space: nowrap;
}

.lc-threshold-input {
  min-height: 44px;
  max-width: 84px;
  padding: 0.55rem 0.7rem;
  text-align: center;
}

.lc-counter-list {
  display: grid;
  gap: 0.6rem;
}

.lc-counter-row {
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem;
  border-radius: var(--lc-radius-lg);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.lc-counter-row.is-threshold-hit {
  border-color: rgba(201, 162, 39, 0.38);
}

.lc-counter-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.lc-counter-row-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.lc-counter-value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 38px;
  border-radius: var(--lc-radius);
  background: var(--bg-raised);
  font-family: "Teko", var(--font-display), serif;
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: 0.04em;
}

.lc-counter-action-btn {
  min-height: 32px;
  min-width: 38px;
  padding: 0.3rem 0.6rem;
  border-radius: var(--lc-radius);
  border: 1px solid var(--border);
  background: var(--lc-elevated);
  font-size: 0.9rem;
  color: inherit;
  cursor: pointer;
}

.lc-add-counter {
  min-height: 40px;
  justify-content: center;
  padding: 0.75rem;
  border: 1px dashed var(--lc-border-strong);
  border-radius: var(--lc-radius-lg);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.lc-custom-counter-form {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px dashed var(--lc-border-strong);
  border-radius: 16px;
}

.lc-counter-name-input,
.lc-counter-threshold-input,
.lc-turn-input {
  min-height: 40px;
  text-align: left;
  padding: 0.65rem 0.8rem;
}

.lc-counter-threshold-input,
.lc-turn-input {
  text-align: center;
}

.lc-dice-result {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem;
  border-radius: var(--lc-radius-lg);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.lc-dice-total {
  font-family: "Teko", var(--font-display), serif;
  font-size: 2.2rem;
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.lc-dice-breakdown {
  color: var(--lc-text-muted);
  font-size: 0.85rem;
}

.lc-history-list {
  flex-direction: column;
  gap: 0.45rem;
}

.lc-history-item {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0.7rem;
  border-radius: var(--lc-radius);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
}

.lc-history-item strong {
  font-family: "Teko", var(--font-display), serif;
  font-size: 1.12rem;
  line-height: 1;
  letter-spacing: 0.04em;
}

.lc-sheet-backdrop,
.lc-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.36);
}

.lc-dialog-backdrop {
  align-items: center;
  padding: 1rem;
}

.lc-dialog-backdrop .modal {
  border-radius: var(--radius-lg);
}

.lc-sheet {
  width: min(100%, 720px);
  max-height: min(78vh, 720px);
  overflow: auto;
  margin: 0 0.85rem calc(0.85rem + var(--lc-safe-bottom));
  padding: 1rem;
  border-radius: calc(var(--lc-radius-lg) + 4px);
  border: 1px solid var(--lc-border);
  background: var(--lc-surface);
  box-shadow: var(--lc-shadow);
}

.lc-dice-modal,
.lc-coin-modal,
.lc-counter-modal,
.lc-game-dialog {
  gap: 0.75rem;
}

.lc-dice-modal .modal-header,
.lc-coin-modal .modal-header,
.lc-counter-modal .modal-header,
.lc-game-dialog .modal-header {
  margin-bottom: 0;
}

.lc-dice-modal .modal-title,
.lc-coin-modal .modal-title,
.lc-counter-modal .modal-title {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lc-dice-close,
.lc-coin-close,
.lc-counter-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
}

.lc-dice-modal {
  --modal-max-width: 480px;
  position: relative;
}

.lc-dice-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.lc-dice-field {
  display: grid;
  gap: 0.35rem;
}

.lc-dice-select {
  cursor: pointer;
}

.lc-dice-output {
  resize: none;
  min-height: 90px;
}

.lc-coin-modal {
  --modal-max-width: 380px;
  position: relative;
}

.lc-coin-output {
  resize: none;
  min-height: 90px;
}

.lc-counter-modal {
  --modal-max-width: 340px;
  position: relative;
}

.lc-ad-slot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  height: var(--lc-ad-height);
  padding: 0.9rem 1rem calc(0.9rem + var(--lc-safe-bottom));
  border-top: 1px solid var(--lc-border);
  background: rgba(8, 8, 8, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

[data-theme="light"] .lc-ad-slot {
  background: rgba(240, 233, 223, 0.98);
}

.lc-ad-slot span {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lc-text-dim);
}

.lc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 768px) {
  .lc-screen__scroll {
    padding: 0;
  }

  .lc-setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .lc-setup-section--full {
    grid-column: 1 / -1;
  }

  .lc-player-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .lc-player-color-group {
    justify-self: end;
  }

  .lc-sidebar {
    display: flex;
  }

  .lc-play-area {
    padding: 0.95rem;
  }

  .lc-toolbar {
    padding: 0.7rem 0.95rem;
  }
}

@media (max-width: 767px) {
  .lc-title {
    max-width: 11ch;
  }

  .lc-toolbar {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    gap: 0.4rem;
    padding-inline: 0.6rem;
  }

  .lc-toolbar-cluster {
    gap: 0.35rem;
  }

  .lc-toolbar-btn {
    padding: 0.6rem 0.65rem;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
  }

  .lc-turn-btn {
    width: 100%;
    min-width: 0;
    font-size: 0.78rem;
  }

  .lc-player-grid {
    gap: 0.45rem;
  }

  .lc-player-card {
    min-height: 120px;
    border-radius: 18px;
  }

  .lc-player-card-inner {
    padding: 0.55rem;
    gap: 0.35rem;
  }

  .lc-life-row {
    gap: 0.25rem;
  }

  .lc-player-card .lc-life-btn {
    min-height: 22px;
    min-width: 38px;
    font-size: 0.72rem;
  }

  .lc-life-value {
    font-size: clamp(1.8rem, 9vw, 3rem);
  }

  .lc-chip-bar {
    gap: 0.35rem;
  }

  .lc-chip {
    padding: 0.32rem 0.48rem;
    min-height: 32px;
  }

  .lc-chip-value {
    font-size: 1rem;
  }

  .lc-layout-tray {
    position: static;
    right: auto;
    bottom: auto;
    grid-column: 1 / -1;
    margin-top: 0.1rem;
  }

  .lc-toolbar:has(.lc-layout-tray) {
    flex: 0 0 auto;
  }

}

/* Landscape phones — prevent cropping, fit everything in view */
@media (max-height: 520px) {
  #life-counter-page {
    --lc-toolbar-height: 52px;
  }

  .lc-toolbar {
    padding-block: 0.3rem;
    gap: 0.35rem;
    padding-inline: 0.6rem;
  }

  .lc-toolbar-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.62rem;
  }

  .lc-turn-btn {
    font-size: 0.72rem;
  }

  .lc-play-area {
    padding: 0.45rem;
  }

  .lc-player-grid {
    gap: 0.35rem;
  }

  .lc-player-card {
    min-height: 0;
    border-radius: 14px;
  }

  .lc-player-card-inner {
    padding: 0.35rem 0.5rem;
    gap: 0.2rem;
  }

  .lc-player-card-head {
    gap: 0.4rem;
  }

  .lc-player-name {
    font-size: 0.6rem;
  }

  .lc-life-row {
    gap: 0.2rem;
  }

  .lc-player-card .lc-life-btn {
    min-height: 18px;
    min-width: 32px;
    font-size: 0.6rem;
    padding-block: 0.1rem;
    padding-inline: 0.3rem;
  }

  .lc-life-value {
    font-size: clamp(1.4rem, 7vh, 2.4rem);
  }

  .lc-chip-bar {
    gap: 0.25rem;
    flex-wrap: nowrap;
  }

  .lc-chip {
    padding: 0.2rem 0.35rem;
    min-height: 26px;
  }

  .lc-chip-value {
    font-size: 0.9rem;
  }
}