/* mtg.css — MTG Life Counter
   Multi-player rotated table layout (2 / 3 / 4 players), Creem neobrutalism.
   Life via tap zones (top half +, bottom half −), plus commander-damage and
   poison trays per player. */

/* ===== Control bar (upright, not rotated) ===== */
.mtg-controls {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 10px; margin-bottom: 14px;
}
.mtg-seg { display: inline-flex; border: var(--nb-border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-hard-sm); }
.mtg-seg button {
  padding: 8px 14px; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  background: var(--color-surface); color: var(--color-text); border: none; border-right: 2px solid var(--nb-ink);
}
.mtg-seg button:last-child { border-right: none; }
.mtg-seg button.active { background: var(--color-accent); }
.mtg-ctrl-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-secondary); margin-right: 2px; }
.mtg-btn {
  padding: 8px 14px; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
  background: var(--color-surface); color: var(--color-text);
  border: var(--nb-border); border-radius: var(--radius-md); box-shadow: var(--shadow-hard-sm);
}
.mtg-btn:active { transform: translate(2px,2px); box-shadow: none; }
.mtg-btn.active { background: var(--color-accent); }

/* ===== Table / stage ===== */
.mtg-stage {
  display: grid; gap: 10px;
  min-height: 70vh;
  margin-bottom: var(--space-lg);
}
.mtg-stage.players-2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.mtg-stage.players-3,
.mtg-stage.players-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.mtg-stage.players-3 .mtg-player:nth-child(3) { grid-column: 1 / span 2; }

/* Opponents across the table read upright when the phone lies flat */
.mtg-stage.players-2 .mtg-player:nth-child(1) { transform: rotate(180deg); }
.mtg-stage.players-3 .mtg-player:nth-child(-n+2) { transform: rotate(180deg); }
.mtg-stage.players-4 .mtg-player:nth-child(-n+2) { transform: rotate(180deg); }

/* ===== Player panel ===== */
.mtg-player {
  position: relative; overflow: hidden;
  border: var(--nb-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  color: #fff; background: var(--pc, #444);
  display: flex; flex-direction: column;
  min-height: 150px;
}
/* Per-player colors */
.mtg-player.pc1 { --pc: #E0403F; }
.mtg-player.pc2 { --pc: #2F6BD6; }
.mtg-player.pc3 { --pc: #2FA85A; }
.mtg-player.pc4 { --pc: #E0A020; }
.mtg-player.is-dead { filter: grayscale(0.85) brightness(0.72); }

/* Tap zones (behind content) */
.mp-zone { position: absolute; left: 0; right: 0; z-index: 1; cursor: pointer; }
.mp-zone-plus { top: 0; height: 50%; }
.mp-zone-minus { bottom: 0; height: 50%; }
.mp-zone:active { background: rgba(255,255,255,0.18); }
.mp-zone-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 54px; height: 54px; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 900; line-height: 1; opacity: .9; pointer-events: none;
  border: 3px solid rgba(255,255,255,.7); border-radius: 50%;
  background: rgba(0,0,0,.16); text-shadow: 1px 1px 0 rgba(0,0,0,.25);
}
.mp-zone-plus .mp-zone-hint { top: 12px; }
.mp-zone-minus .mp-zone-hint { bottom: 12px; }
.mp-zone-plus:active .mp-zone-hint,
.mp-zone-minus:active .mp-zone-hint { background: rgba(255,255,255,.85); color: var(--nb-ink); border-color: #fff; }

/* Floating accumulator pill — shows the net pending change (e.g. −3) */
.mp-delta {
  position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -150%);
  pointer-events: none; font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums;
  padding: 2px 16px; border-radius: 999px; background: var(--nb-ink, #151617); color: #fff;
  border: 2px solid #fff; opacity: 0; transition: opacity .12s ease;
}
.mp-delta.show { opacity: 1; }

/* Foreground content */
.mp-content { position: relative; z-index: 2; pointer-events: none; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px; }
.mp-name {
  pointer-events: auto; z-index: 3;
  max-width: 80%; text-align: center; background: transparent; border: none; color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 800; letter-spacing: .02em;
  text-transform: uppercase; opacity: .92; margin-bottom: 2px;
}
.mp-name:focus { outline: 2px solid #fff; border-radius: 6px; }
.mp-life { pointer-events: auto; z-index: 3; font-size: 68px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; cursor: text; text-shadow: 2px 2px 0 rgba(0,0,0,.25); }
.mp-dead-badge { font-size: 13px; font-weight: 800; margin-top: 4px; letter-spacing: .05em; }

/* Corner controls */
.mp-corner { position: absolute; z-index: 4; display: flex; gap: 6px; pointer-events: auto; }
.mp-corner-tr { top: 8px; right: 8px; }
.mp-corner-bl { bottom: 8px; left: 8px; }
.mp-mini {
  min-width: 30px; height: 30px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
  color: #fff; background: rgba(0,0,0,.28); border: 2px solid rgba(255,255,255,.6); border-radius: 8px;
}
.mp-mini.on { background: #fff; color: var(--nb-ink); }
.mp-mini-chip { gap: 4px; }

/* Trays (commander damage / poison) */
.mp-tray {
  position: absolute; inset: 8px; z-index: 5; pointer-events: auto;
  background: rgba(0,0,0,.82); border: 2px solid rgba(255,255,255,.55); border-radius: 12px;
  padding: 10px; display: none; flex-direction: column; gap: 8px; overflow-y: auto;
}
.mp-tray.open { display: flex; }
.mp-tray-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; opacity: .85; display: flex; justify-content: space-between; align-items: center; }
.mp-tray-close { pointer-events: auto; cursor: pointer; background: none; border: none; color: #fff; font-size: 18px; font-weight: 900; line-height: 1; }
.mp-dmg-row, .mp-poison-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 700; }
.mp-dmg-row .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 6px; border: 1px solid rgba(255,255,255,.7); vertical-align: middle; }
.dot.pc1 { background:#E0403F; } .dot.pc2 { background:#2F6BD6; } .dot.pc3 { background:#2FA85A; } .dot.pc4 { background:#E0A020; }
.mp-step { display: inline-flex; align-items: center; gap: 8px; }
.mp-step button {
  width: 28px; height: 28px; font-family: inherit; font-size: 16px; font-weight: 900; cursor: pointer;
  color: var(--nb-ink); background: #fff; border: 2px solid var(--nb-ink); border-radius: 7px; line-height: 1;
}
.mp-step .val { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
.mp-step .val.warn { color: #ffd35c; }

/* First-player highlight */
.mtg-player.is-first::after {
  content: "FIRST"; position: absolute; z-index: 6; top: 50%; left: 50%;
  transform: translate(-50%,-50%) rotate(-12deg);
  font-size: 30px; font-weight: 900; letter-spacing: .1em; color: #fff;
  text-shadow: 2px 2px 0 var(--nb-ink); pointer-events: none;
  animation: mtgfirst 1.4s ease forwards;
}
@keyframes mtgfirst { 0%{opacity:0;transform:translate(-50%,-50%) rotate(-12deg) scale(.4);} 15%{opacity:1;transform:translate(-50%,-50%) rotate(-12deg) scale(1.1);} 80%{opacity:1;} 100%{opacity:0;} }

/* ===== Match log ===== */
.mtg-log-wrap { margin-bottom: var(--space-lg); }
.mtg-log-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mtg-log-title { font-family: var(--font-display); font-size: 20px; color: var(--color-text); }
.mtg-log {
  list-style: none; max-height: 250px; overflow-y: auto;
  border: var(--nb-border); border-radius: var(--radius-md); box-shadow: var(--shadow-hard-sm);
  background: var(--color-surface); padding: 6px 10px; font-size: 14px;
}
.mtg-log li { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px dashed color-mix(in srgb, var(--color-text) 18%, transparent); color: var(--color-text); }
.mtg-log li:last-child { border-bottom: none; }
.mtg-log .log-empty { justify-content: center; color: var(--color-text-tertiary); }
.mtg-log .log-turn { justify-content: center; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--color-text-secondary); background: var(--color-bg); border-radius: 6px; }
.log-p { font-weight: 800; color: #fff; padding: 1px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.log-p.pc1 { background: #E0403F; } .log-p.pc2 { background: #2F6BD6; } .log-p.pc3 { background: #2FA85A; } .log-p.pc4 { background: #E0A020; }
.log-arrow { color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.log-d { font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; }
.log-d.up { color: #2FA85A; } .log-d.down { color: #E0403F; }
.log-tag { margin-left: auto; font-size: 12px; color: var(--color-text-secondary); }

@media (max-width: 560px) {
  .mp-life { font-size: 54px; }
  .mtg-stage { min-height: 74vh; }
  .mp-zone-hint { width: 46px; height: 46px; font-size: 32px; }
}
