:root {
  --accent: #c52828;
  --primary: #d9a066;
  --secondary: #2b4d33;
  --paper: #f6f1e4;
  --paper-line: #b9c4d8;
  --ink: #2b2b2b;
  --wood-dark: #a36a35;
  --wood: #c08a4f;
  --wood-light: #d9a066;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive, serif;
  background: #6b4a2a;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ===== Clipboard shell ===== */
.clipboard {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.12), transparent 40%),
    linear-gradient(115deg, var(--wood-dark), var(--wood) 45%, var(--wood-light));
  box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
}

.metal-clip {
  position: relative;
  z-index: 5;
  height: 46px;
  flex: 0 0 46px;
  background: linear-gradient(180deg, #d8dde3, #9aa4ae 55%, #6c7782);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.35);
}
.metal-clip::before {
  content: "";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 34%; height: 10px;
  background: linear-gradient(180deg, #f0f3f6, #aab3bd);
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.metal-clip::after {
  content: "";
  position: absolute;
  top: 20px; left: 0; right: 0;
  height: 6px;
  background: rgba(0,0,0,0.18);
}

.paper {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    var(--paper-line) 27px,
    var(--paper-line) 28px
  );
  border-left: 2px solid #d8d2c0;
  border-right: 2px solid #d8d2c0;
  overflow-y: auto;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.paper::before {
  content: "";
  position: sticky;
  top: 0; display: block;
  height: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.12), transparent);
  z-index: 2;
}

.content { padding: 6px 16px 30px; }

.app-header {
  text-align: center;
  padding: 4px 0 10px;
}
.brand {
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive, serif;
  font-size: 34px;
  color: var(--ink);
  letter-spacing: 1px;
  transform: rotate(-2deg);
}
.tagline {
  font-size: 13px;
  color: #7a7055;
  transform: rotate(-2deg);
}

.paper-heading {
  font-size: 16px;
  font-weight: bold;
  color: #5a4a3a;
  margin: 18px 0 10px;
  border-bottom: 1px dashed #cbbf9f;
  padding-bottom: 4px;
}

/* ===== Dashboard tally cards ===== */
.tally-row {
  display: flex;
  gap: 10px;
  margin: 6px 0 0;
}
.tally-card {
  position: relative;
  flex: 1;
  background: #fffdf3;
  border: 2px solid #cdc2a2;
  border-radius: 6px;
  box-shadow: 0 3px 4px rgba(0,0,0,0.2), inset 0 -2px 0 rgba(0,0,0,0.05);
  padding: 10px;
  text-align: center;
  transform: rotate(-1deg);
}
.tally-card:nth-child(2) { transform: rotate(1deg); }
.tally-label {
  display: block;
  font-size: 12px;
  color: #7a7055;
}
.tally-num {
  display: block;
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive, serif;
  font-size: 40px;
  line-height: 1.1;
  color: #333;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.08);
}
.eraser {
  position: absolute;
  bottom: 6px; left: 6px;
  width: 55%; height: 8px;
  background: rgba(120,120,120,0.14);
  border-radius: 40%;
  filter: blur(1px);
}

.quick-log {
  display: block;
  margin: 18px auto 4px;
  width: 64px; height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 5px 8px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.25);
  color: #fff;
  cursor: pointer;
  position: relative;
}
.quick-log::before {
  content: "";
  position: absolute; inset: 14px;
  background: #fff;
  -webkit-mask: radial-gradient(circle at 50% 30%, transparent 0 26%, #000 27% 42%, transparent 43%);
          mask: radial-gradient(circle at 50% 30%, transparent 0 26%, #000 27% 42%, transparent 43%);
}
.quick-log::after {
  content: "Log";
  position: absolute;
  bottom: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: #5a4a3a;
  white-space: nowrap;
}

/* ===== Session card (torn paper) ===== */
.session-card {
  position: relative;
  margin: 14px 0;
  padding: 12px 14px 20px 18px;
  background:
    linear-gradient(90deg, var(--stripe) 0, var(--stripe) 7px, transparent 7px),
    #fffdf3;
  border-radius: 3px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.22);
  border-top: 1px dashed rgba(0,0,0,0.08);
}
.session-card::before,
.session-card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; height: 8px;
  background:
    radial-gradient(circle at 12% 0, transparent 6px, #fffdf3 6.5px),
    radial-gradient(circle at 38% 0, transparent 5px, #fffdf3 5.5px),
    radial-gradient(circle at 68% 0, transparent 7px, #fffdf3 7.5px),
    radial-gradient(circle at 90% 0, transparent 5px, #fffdf3 5.5px);
  background-size: 9px 8px;
  background-repeat: repeat-x;
}
.session-card::before { top: -6px; }
.session-card::after {
  bottom: -6px;
  transform: scaleY(-1);
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.game-name {
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive, serif;
  font-size: 20px;
  color: #111;
  font-weight: bold;
  letter-spacing: 0.2px;
  word-break: break-word;
}
.date-stamp {
  flex: 0 0 auto;
  display: inline-block;
  border: 2px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: bold;
  padding: 5px 6px;
  line-height: 1;
  transform: rotate(6deg);
  box-shadow: 0 0 0 1px rgba(197,40,40,0.25);
}
.card-players {
  margin-top: 4px;
  font-size: 13px;
  color: #6a6046;
}
.card-notes {
  margin-top: 6px;
  font-size: 13px;
  color: #555;
  padding-right: 24px;
}
.card-pencil {
  position: absolute;
  bottom: 8px; right: 12px;
  width: 18px; height: 7px;
  background: #8a5a2b;
  transform: rotate(-30deg);
  border-radius: 3px;
  opacity: 0.8;
}

/* ===== Recent list on dashboard ===== */
.recent-list .session-card { cursor: pointer; }

/* ===== Form ===== */
.score-form .field {
  display: block;
  margin: 12px 0;
}
.score-form span {
  display: block;
  font-size: 13px;
  color: #7a7055;
  margin-bottom: 4px;
}
.score-form input,
.score-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #d8cfae;
  border-radius: 6px;
  background: #fffdf3;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}
.score-form input:focus,
.score-form textarea:focus {
  outline: none;
  border-color: var(--secondary);
}
.error {
  display: none;
  color: var(--accent);
  font-size: 12px;
  margin-top: 4px;
}
.score-form.invalid #game-error { display: block; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
.btn.primary { background: var(--secondary); color: #fff; }
.btn.ghost { background: #e6dcc0; color: #5a4a3a; }
.btn.danger { background: var(--accent); color: #fff; }

/* ===== Search ===== */
.search-wrap { margin: 6px 0 14px; }
.search-wrap input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #d8cfae;
  border-radius: 20px;
  background: #fffdf3;
  font-family: inherit;
  font-size: 15px;
}

/* ===== Games list ===== */
.games-list .game-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  padding: 12px 14px;
  background: #fffdf3;
  border-left: 7px solid var(--stripe, var(--primary));
  border-radius: 3px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.18);
  cursor: pointer;
}
.game-row .g-name {
  font-family: "Comic Sans MS", "Segoe Print", "Bradley Hand", cursive, serif;
  font-size: 17px;
  font-weight: bold;
}
.game-row .g-count {
  font-size: 14px;
  color: #7a7055;
}

/* ===== Empty state ===== */
.empty-slip {
  margin: 20px 8px;
  padding: 22px;
  text-align: center;
  background: #fffdf3;
  border-radius: 3px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.18);
  color: #7a7055;
  font-size: 14px;
}

/* ===== Confirmation ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,25,10,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.confirm-slip {
  width: 80%;
  max-width: 320px;
  background: var(--paper);
  border-radius: 6px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.confirm-slip p { font-size: 16px; margin-bottom: 16px; }
.confirm-actions { display: flex; gap: 10px; }

/* ===== Bottom tab bar (wooden pawn bases) ===== */
.tab-bar {
  flex: 0 0 auto;
  height: calc(62px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border-top: 3px solid #7a4d24;
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.3);
  position: relative;
  z-index: 5;
}

.pawn {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  flex: 1;
  max-width: 90px;
}

.pawn-cap {
  display: block;
  width: 42px;
  height: 22px;
  border-radius: 50% 50% 8px 8px / 60% 60% 20% 20%;
  background: var(--wood);
  box-shadow: inset 0 -4px 4px rgba(0,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.3);
}
.pawn-cap::before {
  content: "";
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 5px;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
}

.pawn-label {
  margin-top: 5px;
  font-size: 10px;
  color: #4a3416;
  font-weight: bold;
}

/* inactive: matte, flat, worn */
.pawn:not(.active) .pawn-cap {
  background: linear-gradient(180deg, #c89a60, #a3703c);
  box-shadow: inset 0 -3px 5px rgba(0,0,0,0.35);
  height: 18px;
  margin-top: 4px;
  filter: saturate(0.9);
}
.pawn:not(.active) .pawn-label { color: #7a5a32; }

/* active: glossy, raised, drop shadow */
.pawn.active .pawn-cap {
  height: 28px;
  background: linear-gradient(160deg, #f0c890, var(--wood-light) 45%, #a9763d);
  box-shadow: 0 -4px 8px rgba(0,0,0,0.4), inset 0 3px 4px rgba(255,255,255,0.6);
  position: relative;
}
.pawn.active .pawn-cap::after {
  content: "";
  position: absolute;
  top: 3px; left: 8px; right: 8px;
  height: 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
}
.pawn.active .pawn-label { color: #2f2008; }