/* Dice pair tracker — HunterKiller */

:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-hover: #232d3b;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3d9cf5;
  --accent-dim: rgba(61, 156, 245, 0.15);
  --success: #4ade80;
  --dice-face: #f5f0e8;
  --pip: #1a1a1a;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

section {
  margin-bottom: 1.75rem;
}

section h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

.dice-columns {
  display: flex;
  flex-direction: row;
  gap: 1.25rem;
  justify-content: center;
  align-items: flex-start;
}

.dice-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Two columns of three faces: 1–3 | 4–6; one framed group per column */
.dice-stack {
  display: grid;
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
  gap: 0.45rem;
  column-gap: 0.55rem;
  justify-items: center;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
}

.die-btn {
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 0.2rem;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.die-btn:hover {
  background: var(--surface-hover);
}

.die-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.die-btn.selected {
  background: var(--accent-dim);
  box-shadow: 0 0 0 2px var(--accent);
}

.die-btn svg {
  display: block;
  width: 52px;
  height: 52px;
}

/* Cut-out pips: fill is masked; edge rect draws outer border only */
.dice-face-fill {
  fill: var(--dice-face, #f5f0e8);
}

.dice-face-edge {
  fill: none;
  stroke: #c4b8a8;
  stroke-width: 1.5;
}

.pattern-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    visibility 0.28s ease;
}

.pattern-modal.pattern-modal--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pattern-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.pattern-modal__sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 22rem;
  border-radius: 0;
}

.pattern-panel {
  margin: 0;
  background: #991b1b;
  color: #fef2f2;
  border: 2px solid #7f1d1d;
  border-radius: 0;
  padding: 1rem 1.15rem;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.pattern-panel ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  text-align: left;
  color: #fef2f2;
}

.pattern-panel li {
  margin: 0.2rem 0;
  font-weight: 500;
}

.history-toolbar-actions {
  display: flex;
  width: 100%;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.history-toolbar-actions .btn-tool {
  flex: 1 1 0;
  min-width: 0;
}

.btn-tool {
  appearance: none;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.55rem 0.5rem;
  cursor: pointer;
  text-align: center;
  color: #f8fafc;
  transition: filter 0.15s, box-shadow 0.15s;
}

.btn-tool:hover {
  filter: brightness(1.1);
}

.btn-tool:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-tool-point {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #60a5fa;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.btn-tool-remove {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border-color: #fbbf24;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.btn-tool-clear {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border-color: #f87171;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset;
}

.btn-point-toggle[aria-pressed="true"],
.btn-remove-toggle[aria-pressed="true"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 0 0 2px rgba(255, 255, 255, 0.35);
  filter: brightness(1.12);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.75rem 0.65rem;
  align-items: start;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: 0.2rem;
  margin: 0;
  font-size: 0.875rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 0;
  transition: background 0.15s;
}

.history-list--remove-mode .history-item {
  cursor: pointer;
}

.history-list--remove-mode .history-item:hover {
  background: var(--accent-dim);
}

.history-list--point-mode .history-item {
  cursor: pointer;
}

.history-list--point-mode .history-item:hover {
  background: var(--accent-dim);
}

.history-item.is-point {
  position: relative;
  z-index: 0;
}

/* True circle (equal width/height), centered, large enough for both dice + sum */
.history-item.is-point::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 51.2px;
  height: 51.2px;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.history-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.2rem;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding-inline: 0.35rem;
  box-sizing: border-box;
}

.history-dice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.history-pair svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.history-sum {
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  text-align: center;
  min-width: 0;
  max-width: 100%;
}

/* Sum 7: red face (pips are real holes in the masked fill) */
.history-item--seven .history-pair .dice-face-fill {
  fill: #e53935;
}

.history-item--seven .history-pair .dice-face-edge {
  stroke: #e53935;
}

.history-item--seven .history-sum {
  color: #e53935;
}

/* Sum 7 immediately after another 7 (newest-first list: older neighbor is also 7) */
.history-item--seven-blue .history-pair .dice-face-fill {
  fill: #1e88e5;
}

.history-item--seven-blue .history-pair .dice-face-edge {
  stroke: #1e88e5;
}

.history-item--seven-blue .history-sum {
  color: #1e88e5;
}

/* Doubles 2/2, 3/3, 4/4, 5/5: bright green face */
.history-item--green-pair .history-pair .dice-face-fill {
  fill: #39ff14;
}

.history-item--green-pair .history-pair .dice-face-edge {
  stroke: #39ff14;
}

.history-item--green-pair .history-sum {
  color: #39ff14;
}

.history-empty {
  grid-column: 1 / -1;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.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;
}
