/* Paper Golf · flat GUI windows, no glass / blur / soft shadows */

body.page-paper-golf .wrap {
  max-width: 1120px;
}

/* Course terrain tokens · high contrast, paper-notebook feel */
html[data-theme="dark"] body.page-paper-golf {
  --pg-board: #1a1e26;
  --pg-rough: #252a34;
  --pg-dot: #6a7384;
  --pg-fairway: #3d8f55;
  --pg-fairway-dot: #2a6b3c;
  --pg-sand: #c9a03a;
  --pg-sand-dot: #8a6a18;
  --pg-water-a: #2a6fad;
  --pg-water-b: #1a4a78;
  --pg-tree: #d8e0ec;
  --pg-cup-ring: #f1f3f6;
  --pg-cup-fill: #0c1018;
  --pg-ball: #f1f3f6;
  --pg-ball-ring: #0a0a0a;
}
html[data-theme="light"] body.page-paper-golf {
  --pg-board: #dce3ea;
  --pg-rough: #eef2f6;
  --pg-dot: #8a93a0;
  --pg-fairway: #6bb87a;
  --pg-fairway-dot: #3d7a4a;
  --pg-sand: #e0b84a;
  --pg-sand-dot: #8a6a18;
  --pg-water-a: #5aa0d8;
  --pg-water-b: #2e6fa8;
  --pg-tree: #1a3020;
  --pg-cup-ring: #111111;
  --pg-cup-fill: #f7f3e9;
  --pg-ball: #111111;
  --pg-ball-ring: #ffffff;
}

/* Accent titlebars (tool pattern) */
body.page-paper-golf .titlebar.accent-bar {
  background: var(--c);
  border-bottom-color: var(--ink);
}
body.page-paper-golf .titlebar.accent-bar .dot-close {
  background: #fff;
  border-color: #0a0a0a;
}
body.page-paper-golf .titlebar.accent-bar .tname {
  color: #0c1322;
  font-weight: 700;
}
body.page-paper-golf .titlebar.accent-bar .grip {
  opacity: 0.55;
}

/* Stats strip */
.pg-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1.25rem 0 1.35rem;
}
.pg-stats .stat {
  background: var(--win);
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 0.55rem 0.7rem;
  min-width: 0;
}
.pg-stats .k {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pg-stats .v {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-hi);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-stats .stat-par {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.pg-stats .v.good { color: var(--c-green); }
.pg-stats .v.bad { color: var(--c-red); }

/* Main layout · course gets the wide column */
.pg-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 280px);
  gap: 1.15rem;
  align-items: start;
}
.pg-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Course */
.pg-course-body {
  padding: 0.85rem;
}
.pg-course-scroll {
  overflow: auto;
  max-height: min(78vh, 780px);
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  background: var(--pg-board);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.pg-course-stage {
  position: relative;
  width: max-content;
  margin: 0 auto;
}
.pg-grid {
  display: grid;
  gap: 0;
  width: max-content;
  padding: 12px;
  position: relative;
  z-index: 1;
  background: var(--pg-rough);
}
.pg-paths {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.pg-paths line {
  stroke: var(--c-orange);
  stroke-width: 3.5;
  stroke-linecap: round;
  opacity: 1;
}

/* Cells */
.pg-cell {
  width: 28px;
  height: 28px;
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  box-sizing: border-box;
}
.pg-cell::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pg-dot);
  opacity: 0.85;
}

/* Terrain fills · solid blocks so shapes read at a glance */
.pg-cell.t-fairway {
  background: var(--pg-fairway);
  border-radius: 1px;
}
.pg-cell.t-fairway::after {
  background: var(--pg-fairway-dot);
  opacity: 0.55;
}
.pg-cell.t-sand {
  background: var(--pg-sand);
  border-radius: 1px;
}
.pg-cell.t-sand::after {
  background: var(--pg-sand-dot);
  opacity: 0.65;
}
.pg-cell.t-water {
  background: repeating-linear-gradient(
    -45deg,
    var(--pg-water-a) 0 3px,
    var(--pg-water-b) 3px 6px
  );
  border-radius: 1px;
}
.pg-cell.t-water::after {
  background: rgba(255, 255, 255, 0.35);
  opacity: 0.5;
}

.pg-cell.t-tree {
  background: transparent;
}
.pg-cell.t-tree::before {
  content: "▲";
  position: absolute;
  font-size: 16px;
  color: var(--pg-tree);
  z-index: 1;
  opacity: 1;
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 0 0 var(--pg-tree);
}
.pg-cell.t-tree::after { opacity: 0; }

.pg-cell.t-hole {
  background: var(--pg-fairway);
  border-radius: 1px;
}
.pg-cell.t-hole::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--pg-cup-ring);
  border-radius: 50%;
  background: var(--pg-cup-fill);
  z-index: 1;
  box-shadow: inset 0 0 0 3px var(--pg-cup-ring);
}
.pg-cell.t-hole::after { opacity: 0; }

.pg-cell.is-ball::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pg-ball);
  border: 2px solid var(--pg-ball-ring);
  z-index: 3;
  box-shadow: 1px 1px 0 var(--shadow);
}
.pg-cell.is-ball.t-hole::before {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  background: var(--c-gold);
  box-shadow: 1px 1px 0 var(--shadow);
}
.pg-cell.is-ball::after { opacity: 0; }

.pg-cell.is-tee-mark:not(.is-ball)::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-silver);
  border: 1.5px solid var(--ink);
  z-index: 1;
  opacity: 0.85;
}

/* Valid landing targets · high-visibility gold ring */
.pg-cell.is-valid {
  cursor: pointer;
  outline: 2.5px solid var(--c-gold);
  outline-offset: -2px;
  z-index: 2;
  border-radius: 3px;
  box-shadow: inset 0 0 0 10px rgba(242, 201, 76, 0.35);
  animation: pg-pulse 1.1s ease-in-out infinite;
}
.pg-cell.is-valid:hover,
.pg-cell.is-valid:focus-visible {
  outline-color: var(--c-orange);
  box-shadow: inset 0 0 0 10px rgba(242, 140, 76, 0.45);
  animation: none;
}
.pg-cell.is-valid-cup {
  outline-color: #fff;
  box-shadow: inset 0 0 0 10px rgba(70, 194, 106, 0.45);
}
@keyframes pg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

.pg-hole-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-mid);
}
.pg-hole-foot strong {
  color: var(--text-hi);
  font-weight: 700;
}

/* Shot panel */
.pg-shot-body {
  padding: 1rem 1.15rem 1.1rem;
}

/* Die */
.pg-die-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}
.pg-die {
  width: 64px;
  height: 64px;
  flex: none;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: var(--win-2);
  box-shadow: 4px 4px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-die.is-rolling {
  animation: pg-shake 0.45s ease-in-out;
}
@keyframes pg-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-3px, 2px) rotate(-6deg); }
  40% { transform: translate(3px, -2px) rotate(5deg); }
  60% { transform: translate(-2px, -1px) rotate(-3deg); }
  80% { transform: translate(2px, 1px) rotate(3deg); }
}
.pg-die-face {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-hi);
  line-height: 1;
}
.pg-die-meta { min-width: 0; }
.pg-dist {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-hi);
}
.pg-dist-sub {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  line-height: 1.35;
}

.pg-prompt {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.45;
  margin-bottom: 0.85rem;
  min-height: 2.6em;
}

.pg-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.pg-actions .btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.55rem 0.65rem;
  justify-content: center;
  box-shadow: 3px 3px 0 var(--ink);
}
.pg-actions .btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}
.pg-actions .btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}
.pg-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0 var(--ink);
}
.pg-actions .btn-primary {
  grid-column: 1 / -1;
}
/* .btn sets display:inline-flex, which overrides the UA [hidden] rule */
.pg-actions #btn-gimme[hidden] {
  display: none !important;
}
.pg-actions #btn-gimme:not([hidden]) {
  display: inline-flex;
  grid-column: 1 / -1;
  background: var(--c-green);
  color: #0c1322;
}

.pg-shot-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--ink);
}
.pg-status-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #0c1322;
  background: var(--c-gold);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
}
.pg-cancel {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mid);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
}
.pg-cancel:hover {
  color: var(--text-hi);
  background: var(--win-2);
}

/* Legend */
.pg-legend-body {
  padding: 1rem 1.15rem 1.1rem;
}
.pg-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-mid);
}
.pg-legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.lg {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}
.lg-rough { background: var(--pg-rough); }
.lg-rough::after {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--pg-dot);
}
.lg-fairway { background: var(--pg-fairway); }
.lg-sand { background: var(--pg-sand); }
.lg-water {
  background: repeating-linear-gradient(
    -45deg,
    var(--pg-water-a) 0 2px,
    var(--pg-water-b) 2px 4px
  );
}
.lg-tree::before { content: "▲"; font-size: 10px; color: var(--pg-tree); }
.lg-hole {
  border-radius: 50%;
  background: var(--pg-cup-fill);
  box-shadow: inset 0 0 0 3px var(--pg-cup-ring);
}
.lg-ball {
  border-radius: 50%;
  background: var(--pg-ball);
  border-color: var(--pg-ball-ring);
}
.lg-valid {
  background: var(--pg-fairway);
  outline: 2px solid var(--c-gold);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 4px rgba(242, 201, 76, 0.4);
}

/* Scorecard */
.pg-score-win { margin-top: 1.25rem; }
.pg-score-scroll {
  overflow-x: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
}
.pg-scorecard {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.72rem;
  min-width: 720px;
}
.pg-scorecard th,
.pg-scorecard td {
  border: 1px solid var(--ink);
  padding: 0.4rem 0.35rem;
  text-align: center;
  color: var(--text-mid);
}
.pg-scorecard thead th {
  background: var(--win-2);
  color: var(--text-hi);
  font-weight: 700;
}
.pg-scorecard th[scope="row"] {
  text-align: left;
  padding-left: 0.55rem;
  background: var(--win-2);
  color: var(--text-hi);
  font-weight: 700;
  white-space: nowrap;
}
.pg-scorecard .out,
.pg-scorecard .in,
.pg-scorecard .tot {
  background: color-mix(in srgb, var(--c-orange) 18%, var(--win-2));
  font-weight: 700;
  color: var(--text-hi);
}
.pg-scorecard .score-row td {
  color: var(--text-hi);
  font-weight: 700;
  font-size: 0.8rem;
}
.pg-scorecard td.is-current {
  outline: 2px solid var(--c-gold);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--c-gold) 22%, var(--win));
}
.pg-scorecard td.is-birdie { color: var(--c-green); }
.pg-scorecard td.is-bogey { color: var(--c-red); }
.pg-scorecard .rel-row td {
  font-size: 0.68rem;
  color: var(--text-dim);
}
.pg-score-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}
.pg-score-actions .btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.5rem 0.85rem;
  box-shadow: 3px 3px 0 var(--ink);
}

/* Modals */
.pg-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.pg-modal[hidden] { display: none; }
.pg-modal-win {
  width: min(360px, 100%);
}
.pg-modal-win .win-body {
  padding: 1.15rem 1.25rem 1.3rem;
  text-align: center;
}
.pg-modal-win h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}
.pg-modal-score {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-hi);
  margin-bottom: 0.25rem;
}
.pg-modal-note {
  font-size: 0.88rem;
  color: var(--text-mid);
  margin-bottom: 1rem;
}
.pg-modal-win .btn {
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* Scorecard out/in/tot still use color-mix; keep a solid fallback */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .pg-scorecard .out,
  .pg-scorecard .in,
  .pg-scorecard .tot { background: var(--win-2); }
  .pg-modal { background: rgba(0, 0, 0, 0.45); }
  .pg-scorecard td.is-current { background: var(--c-gold); }
}

@media (max-width: 900px) {
  .pg-layout {
    grid-template-columns: 1fr;
  }
  .pg-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .pg-course-scroll {
    max-height: min(70vh, 640px);
  }
  .pg-cell {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .pg-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pg-cell {
    width: 20px;
    height: 20px;
  }
  .pg-actions {
    grid-template-columns: 1fr;
  }
  .pg-actions .btn-primary {
    grid-column: auto;
  }
}
