/* Meeple Minutes — tabletop score-pad theme */
:root {
  --primary: #2f5d50;
  --primary-deep: #24493f;
  --secondary: #e9dcc3;
  --cream: #f7efdd;
  --accent: #d98e32;
  --wood-dark: #6b4a2f;
  --wood-mid: #8a5a2e;
  --wood-light: #b98a52;
  --ink: #3d3227;
  --ink-soft: #7a6a54;
  --playing: #2f5d50;
  --radius: 12px;
  --nav-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,0.06), rgba(0,0,0,0.18)),
    var(--primary);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
}

/* ---------- Wooden dice-tray header ---------- */
.dice-tray {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(0,0,0,0.10)),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 3px, rgba(255,255,255,0.04) 3px 9px),
    linear-gradient(180deg, var(--wood-light), var(--wood-mid) 55%, var(--wood-dark));
  border-bottom: 3px solid rgba(0,0,0,0.25);
  box-shadow: 0 3px 10px rgba(0,0,0,0.30);
}

.tray-tokens { display: flex; gap: 14px; }

.token {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.token-num {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #3a2413;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.45), rgba(255,255,255,0) 55%),
    radial-gradient(circle at 50% 120%, rgba(0,0,0,0.30), rgba(0,0,0,0) 60%),
    linear-gradient(160deg, #c99b62, #9c6b38);
  border: 3px solid rgba(59,38,19,0.55);
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.35), inset 0 -3px 5px rgba(0,0,0,0.30), 0 2px 4px rgba(0,0,0,0.30);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
.token-planned .token-num { border-color: var(--accent); }
.token-played .token-num { border-color: var(--secondary); }

.token-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  font-weight: 700;
}

/* New Session quick action: small wooden die */
.die-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
}

.die-face {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  padding: 7px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.35), rgba(255,255,255,0) 55%),
    linear-gradient(150deg, var(--accent), #b06f1e);
  border: 3px solid rgba(74,42,10,0.55);
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.30), inset 0 -3px 5px rgba(0,0,0,0.28), 0 3px 6px rgba(0,0,0,0.35);
  transform: rotate(-6deg);
  transition: transform 0.15s ease;
}
.die-button:active .die-face { transform: rotate(0deg) scale(0.94); }

.dp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
  display: none;
  align-self: center;
  justify-self: center;
}
.dp:only-child, .die-face .dp, .empty-die .dp { display: block; }
.die-face .dp.p1, .empty-die .dp.p1 { grid-area: 2 / 2; }
.die-face .dp.p2, .empty-die .dp.p2 { grid-area: 1 / 1; }
.die-face .dp.p3, .empty-die .dp.p3 { grid-area: 3 / 3; }
.die-face .dp.p5, .empty-die .dp.p5 { grid-area: 1 / 3; }
.empty-die .dp.p4 { grid-area: 1 / 1; }

.die-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  font-weight: 700;
}

/* ---------- Panels & titles ---------- */
.tab-panel { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stack-title {
  color: var(--secondary);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 10px 2px 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ---------- Cream score-pad cards ---------- */
.card-stack { display: flex; flex-direction: column; gap: 10px; }

.pad-card {
  display: flex;
  width: 100%;
  text-align: left;
  border: none;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(47,93,80,0.12) 27px 28px),
    linear-gradient(180deg, var(--cream), #efe4cb);
  box-shadow: 0 2px 5px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(107,74,47,0.25);
  min-height: 76px;
}
button.pad-card { -webkit-appearance: none; }

.pip-strip {
  flex: 0 0 46px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  padding: 10px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.12), rgba(0,0,0,0.05));
  border-right: 2px solid rgba(107,74,47,0.35);
}
.pip-strip .pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: none;
  align-self: center;
  justify-self: center;
}
.pip-strip .pip.on { display: block; }
.pip-strip .pip.c1 { grid-area: 1 / 1; }
.pip-strip .pip.c2 { grid-area: 1 / 3; }
.pip-strip .pip.c3 { grid-area: 2 / 2; }
.pip-strip .pip.c4 { grid-area: 3 / 1; }
.pip-strip .pip.c5 { grid-area: 3 / 3; }
.pip-strip .pip.c6 { grid-area: 2 / 1; }
.pip-strip .pip.c7 { grid-area: 2 / 3; }

.status-planned  { background: linear-gradient(180deg, #e59a3f, #b06f1e); }
.status-playing  { background: linear-gradient(180deg, #3d7263, var(--primary-deep)); }
.status-played   { background: linear-gradient(180deg, #8a5a2e, var(--wood-dark)); }
.status-planned .pip, .status-playing .pip, .status-played .pip { background: var(--cream); box-shadow: inset 0 1px 1px rgba(0,0,0,0.45); }

.pad-body { flex: 1; padding: 10px 12px; min-width: 0; }

.pad-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pad-meta {
  margin-top: 3px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.pad-meta .status-word-planned { color: #b06f1e; }
.pad-meta .status-word-playing { color: var(--primary); }
.pad-meta .status-word-played  { color: var(--wood-mid); }
.pad-note {
  margin-top: 5px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Played tab row actions */
.row-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px 10px 4px;
}
.row-btn {
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 9px 10px;
  cursor: pointer;
  background: var(--primary);
  color: var(--cream);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.row-btn.danger { background: #a04b32; color: #ffe9d9; }

/* ---------- Empty states ---------- */
.empty-state {
  margin-top: 26px;
  text-align: center;
  padding: 20px;
  color: var(--secondary);
}
.empty-die {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  padding: 9px;
  background: linear-gradient(150deg, var(--accent), #b06f1e);
  border: 3px solid rgba(74,42,10,0.55);
  transform: rotate(8deg);
}
.empty-head { font-weight: 700; font-size: 1.05rem; }
.empty-sub { margin-top: 5px; font-size: 0.88rem; opacity: 0.85; max-width: 260px; margin-left: auto; margin-right: auto; }

/* ---------- Add / edit form ---------- */
.form-sheet {
  background:
    repeating-linear-gradient(180deg, transparent 0 29px, rgba(47,93,80,0.12) 29px 30px),
    linear-gradient(180deg, var(--cream), #efe4cb);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(107,74,47,0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wood-mid);
  margin-bottom: 5px;
}
.field .optional { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-soft); }

.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255,255,255,0.65);
  border: 2px solid rgba(107,74,47,0.35);
  border-radius: 9px;
  padding: 12px;
  min-height: 48px;
  outline: none;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  background: #fff;
}
.field.has-error input, .field.has-error select { border-color: #a04b32; }

.field-error {
  margin-top: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #a04b32;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 15px 8px;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.30);
}
.btn-primary { background: linear-gradient(180deg, #3d7263, var(--primary-deep)); color: var(--cream); }
.btn-ghost { background: rgba(233,220,195,0.16); color: var(--secondary); box-shadow: none; border: 2px solid rgba(233,220,195,0.4); }
.btn-danger { background: linear-gradient(180deg, #b45a3d, #8f3d27); color: #ffe9d9; flex: 0 0 34%; }

/* ---------- Find bar ---------- */
.find-bar { margin-bottom: 12px; }
.find-bar input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid rgba(107,74,47,0.4);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  outline: none;
}
.find-bar input:focus { border-color: var(--accent); }

.chip-row { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  flex: 0 0 auto;
  border: 2px solid rgba(233,220,195,0.5);
  background: rgba(0,0,0,0.15);
  color: var(--secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 9px 16px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.is-active { background: var(--secondary); color: var(--primary-deep); border-color: var(--secondary); }
.chip-planned.is-active { background: var(--accent); border-color: var(--accent); color: #3a2413; }
.chip-playing.is-active { background: #4d8a77; border-color: #4d8a77; color: #fff; }
.chip-played.is-active  { background: var(--wood-light); border-color: var(--wood-light); color: #2e1d0e; }

/* ---------- Bottom pawn navigation ---------- */
.pawn-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.22)),
    linear-gradient(180deg, var(--primary-deep), #1c382f);
  border-top: 3px solid rgba(0,0,0,0.35);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

.pawn-tab {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  min-width: 72px;
  min-height: 56px;
}

.pawn {
  width: 30px;
  height: 32px;
  display: block;
  background-color: currentColor;
  clip-path: path("M50 6 C61 6 68 14 68 24 C68 31 64 36 60 40 C71 44 77 53 79 63 L83 80 C84 88 76 93 67 93 L33 93 C24 93 16 88 17 80 L21 63 C23 53 29 44 40 40 C36 36 32 31 32 24 C32 14 39 6 50 6 Z");
  transform: rotate(90deg) scale(0.82);
  opacity: 0.45;
  filter: saturate(0.7);
  transform-origin: 50% 60%;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}
.pawn-sessions { color: #6fc2a8; }
.pawn-add      { color: var(--accent); }
.pawn-played   { color: var(--secondary); }
.pawn-find     { color: #d9a86c; }

.pawn-tab.is-active .pawn {
  transform: none;
  opacity: 1;
  filter: none;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.45));
}

.pawn-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--secondary);
  opacity: 0.55;
}
.pawn-tab.is-active .pawn-label { opacity: 1; color: #fff; }
