/* ── Pub Golf, Gamla Stan ────────────────────────────────────────────── */

:root {
  --ink:        #1b1109;
  --parchment:  #d9c095;
  --gold:       #e0b552;
  --gold-light: #f6dea0;
  --gold-dark:  #8a6a24;
  --ember:      #e08a4a;
  --blood:      #d9584a;

  --shadow: 0 6px 22px rgba(0, 0, 0, .55);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua',
           Georgia, 'Times New Roman', serif;

  --sheet-height: 150px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--serif);
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

.paint-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── Banner ──────────────────────────────────────────────────────────── */
.banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 0;
  pointer-events: none;
}
.banner-inner {
  min-width: 232px; padding: 8px 34px 12px; text-align: center;
  background: linear-gradient(180deg, #e6cfa0 0%, #cdae7b 48%, #b3915f 100%);
  border: 2px solid var(--gold-dark); border-radius: 4px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 240, 200, .45);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 92% 78%, 8% 78%, 0 100%);
}
.banner h1 {
  margin: 0; font-size: clamp(20px, 5.6vw, 28px); font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: #4a2f14; text-shadow: 0 1px 0 rgba(255, 240, 205, .6);
}
.banner p {
  margin: 1px 0 0; font-size: 11px; letter-spacing: .3em;
  text-transform: uppercase; color: #6d4b23;
}

/* ── Map ─────────────────────────────────────────────────────────────── */
.map-view {
  position: absolute; inset: 0;
  overflow: hidden; touch-action: none; cursor: grab;
  background: #14100c;
}
.map-view:active { cursor: grabbing; }

.map-world {
  position: absolute; top: 0; left: 0;
  width: 1337px; height: 1177px;
  transform-origin: 0 0;
  --inv: 1;
}
#mapImage {
  width: 1337px; height: 1177px; display: block;
  user-select: none; -webkit-user-drag: none;
}

.vignette {
  position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%,
    transparent 55%, rgba(15, 9, 4, .35) 82%, rgba(15, 9, 4, .78) 100%);
}

/* ── Route ───────────────────────────────────────────────────────────── */
.route {
  position: absolute; top: 0; left: 0;
  width: 1337px; height: 1177px;
  overflow: visible; pointer-events: none;
}
.route-left {
  stroke: #4a2c12; stroke-linecap: round; stroke-linejoin: round; opacity: .85;
}
.route-done {
  stroke: var(--gold); stroke-linecap: round; stroke-linejoin: round; opacity: .95;
  filter: drop-shadow(0 0 3px rgba(224, 181, 82, .6));
}

/* ── Medallion ───────────────────────────────────────────────────────────
   Built to match the map's own landmark badges: a bevelled brass rim, a deep
   lacquer face, and a gilded symbol with a stamped shadow under it. */
.medallion {
  position: relative; display: block;
  width: var(--size, 44px); height: var(--size, 44px);
  padding: calc(var(--size, 44px) * .088);
  border-radius: 50%;
  background: conic-gradient(from 212deg,
    #6a4a15   0deg, #f8e6ae  52deg, #d0a544 104deg, #8a6423 156deg,
    #6b4b16 202deg, #f3d992 254deg, #c1913a 306deg, #6a4a15 360deg);
  box-shadow: 0 0 0 1.5px #2a1c08, 0 3px 9px rgba(0, 0, 0, .7);
}
.medallion-face {
  display: grid; place-items: center;
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 38% 28%, #4b3823 0%, #2a1d0f 55%, #130d06 100%);
  box-shadow: inset 0 0 0 1.2px #2b1d09, inset 0 2px 7px rgba(0, 0, 0, .85);
}
.medallion svg {
  width: 54%; height: 54%;
  fill: url(#goldFill) #eac66f;
  filter: drop-shadow(0 1px 0 rgba(12, 7, 2, .95));
}

/* ── Markers ─────────────────────────────────────────────────────────── */
.markers { position: absolute; inset: 0; }

.marker {
  position: absolute; padding: 0; border: 0; background: none;
  transform: translate(-50%, -50%) scale(var(--marker-scale, 1));
  display: flex; flex-direction: column; align-items: center;
  color: inherit; font-family: inherit; cursor: pointer;
  --size: 42px;
}

.marker-num {
  position: absolute; top: -5px; right: -6px;
  min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px;
  background: linear-gradient(180deg, #f6e3ac, #c39a3d);
  color: #2a1a06; border: 1.5px solid #5d451399;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

/* Names are hidden when zoomed out — 18 of them would be an unreadable pile.
   The active and the opened hole keep theirs at every zoom level. */
.marker-label {
  position: absolute; top: calc(100% + 3px); left: 50%;
  transform: translateX(-50%);
  width: 118px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; text-align: center; line-height: 1.15;
  color: var(--gold-light);
  text-shadow: 0 1px 2px #120a03, 0 0 6px #120a03, 0 0 2px #120a03;
  opacity: 0; transition: opacity .18s ease; pointer-events: none;
}
.markers.named .marker-label,
.marker.active .marker-label,
.marker.selected .marker-label { opacity: 1; }

/* Played holes dim down and keep their hole number as a trophy. */
.marker.played .medallion { filter: grayscale(.7) brightness(.62); }
.marker.played .marker-label { color: #a8977a; }
.marker.played .marker-num { background: linear-gradient(180deg, #d9e0b8, #6f8455); }

/* The bar you are sitting in right now. */
.marker.current { z-index: 5; --size: 54px; }
.marker.current .medallion { filter: none; animation: gold-pulse 2.1s ease-in-out infinite; }
.marker.current .marker-label { font-size: 12.5px; color: #ffeab8; }

/* A bar you are obliged to play — the booking. */
.marker.needed { z-index: 4; --size: 50px; }
.marker.needed .medallion { box-shadow: 0 0 0 2px #e0b552, 0 3px 12px rgba(0, 0, 0, .75); }
.marker.needed .marker-label { opacity: 1; color: #ffeab8; }

.marker-anchor {
  position: absolute; top: calc(100% + 2px); left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px; border-radius: 8px;
  background: linear-gradient(180deg, #f0d189, #c39a3d);
  color: #2a1a06; border: 1px solid #5d4513;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.marker.needed .marker-label { top: calc(100% + 20px); }
.marker.played .marker-anchor { display: none; }

.marker.selected .medallion { box-shadow: 0 0 0 2px #fff1c9, 0 3px 12px rgba(0, 0, 0, .8); }

@keyframes gold-pulse {
  0%, 100% { box-shadow: 0 0 0 1.5px #2a1c08, 0 3px 9px rgba(0,0,0,.7), 0 0 0 0 rgba(224,181,82,.55); }
  70%      { box-shadow: 0 0 0 1.5px #2a1c08, 0 3px 9px rgba(0,0,0,.7), 0 0 0 16px rgba(224,181,82,0); }
}

/* ── My position ─────────────────────────────────────────────────────── */
.me {
  position: absolute; width: 0; height: 0; z-index: 6;
  transform: translate(-50%, -50%); pointer-events: none;
}
.me-dot, .me-pulse {
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
}
.me-dot {
  background: #f6dea0; border: 2.5px solid #6d4b12;
  box-shadow: 0 0 10px rgba(246, 222, 160, .9);
  transform: scale(var(--inv));
}
.me-pulse {
  background: rgba(246, 222, 160, .35);
  animation: me-ripple 2.4s ease-out infinite;
}
@keyframes me-ripple {
  0%   { opacity: .8; transform: scale(calc(var(--inv) * 1)); }
  100% { opacity: 0;  transform: scale(calc(var(--inv) * 5)); }
}

/* ── Floating controls ───────────────────────────────────────────────── */
.tools, .compass {
  position: absolute; z-index: 41;
  bottom: calc(var(--sheet-height) + 14px);
  transition: bottom .28s cubic-bezier(.22, .7, .28, 1);
}
.tools { right: 12px; display: flex; flex-direction: column; gap: 8px; }
.compass {
  left: 12px; display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 10px;
}

.tool-btn, .compass {
  background: linear-gradient(180deg, #2f2313 0%, #1c130a 100%);
  border: 1.5px solid var(--gold-dark); border-radius: 999px;
  box-shadow: var(--shadow);
}
.tool-btn {
  display: flex; align-items: center; gap: 7px; padding: 9px 13px;
  color: var(--gold-light); font-family: var(--serif);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer;
}
.tool-btn:active { transform: translateY(1px); }
.tool-btn.on { border-color: var(--gold); color: #fff2cd; }
.tool-icon { font-size: 14px; line-height: 1; }

.compass-needle {
  font-size: 19px; line-height: 1; color: var(--gold);
  transform: rotate(-90deg); transition: transform .35s ease;
}
.compass-text { display: flex; flex-direction: column; line-height: 1.15; }
.compass-text b { font-size: 14px; color: var(--gold-light); }
.compass-text span {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: #9a8256;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Toasts ──────────────────────────────────────────────────────────── */
.toasts {
  position: absolute; left: 0; right: 0; z-index: 60;
  top: calc(env(safe-area-inset-top, 0px) + 88px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 16px; pointer-events: none;
}
.toast {
  max-width: 340px; padding: 10px 16px;
  background: linear-gradient(180deg, #e6cfa0, #c19a5e);
  color: #33200c; border: 1.5px solid #6d5219; border-radius: 6px;
  font-size: 13.5px; box-shadow: var(--shadow);
  animation: toast-in .3s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* ── Bottom sheet ────────────────────────────────────────────────────── */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 78vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(35, 24, 13, .97) 0%, rgba(20, 13, 7, .99) 100%);
  border-top: 2px solid var(--gold-dark); border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 34px rgba(0, 0, 0, .6);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.handle {
  display: block; width: 100%; padding: 9px 0 5px;
  background: none; border: 0; cursor: pointer;
}
.handle-bar {
  display: block; width: 46px; height: 4px; margin: 0 auto;
  border-radius: 2px; background: var(--gold-dark);
}

/* The one fixed appointment of the night, pinned above everything else. */
.anchor-strip {
  display: flex; align-items: center; gap: 11px;
  margin: 2px 12px 10px; padding: 8px 12px;
  border: 1px solid rgba(224, 181, 82, .32); border-radius: 10px;
  background: rgba(224, 181, 82, .07);
  cursor: pointer;
}
.anchor-strip.soon   { border-color: rgba(224, 138, 74, .55); background: rgba(224, 138, 74, .1); }
.anchor-strip.urgent { border-color: rgba(217, 88, 74, .6);  background: rgba(217, 88, 74, .12); }
.anchor-time {
  flex: 0 0 auto; font-size: 17px; font-weight: 700; color: var(--gold-light);
  letter-spacing: .04em;
}
.anchor-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.anchor-body b {
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--parchment);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.anchor-body span { font-size: 11.5px; color: #a08a60; }

.now-row { padding: 2px 16px 14px; display: flex; align-items: center; gap: 12px; }
.now-icon { flex: 0 0 auto; --size: 42px; }
.now-text { flex: 1 1 auto; min-width: 0; }
.now-label {
  font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: #9a8256;
}
.now-name {
  font-size: 17px; font-weight: 700; color: var(--gold-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-meta { font-size: 12px; color: #b09b74; }

.soon   { color: var(--ember); font-weight: 700; }
.urgent { color: var(--blood); font-weight: 700; }

.btn {
  flex: 0 0 auto; padding: 9px 14px; border-radius: 8px;
  background: linear-gradient(180deg, #e6cfa0, #bc9351);
  color: #33200c; border: 1.5px solid #6d5219;
  font-family: var(--serif); font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: none; color: var(--gold); border-color: var(--gold-dark); }

/* Collapsed: only the "now" row shows; open reveals the card */
.sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 12px 16px;
  opacity: 0; max-height: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.sheet.open .sheet-body { opacity: 1; max-height: none; pointer-events: auto; }

.list { list-style: none; margin: 0; padding: 0; }

.item {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px;
  align-items: start;
  padding: 11px 8px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
}
.item + .item { box-shadow: 0 -1px 0 rgba(224, 181, 82, .13); }
.item.active { background: rgba(224, 181, 82, .09); border-color: rgba(224, 181, 82, .38); }
.item.needed { border-color: rgba(224, 181, 82, .3); }
.item.played { opacity: .58; }

.list-heading {
  padding: 14px 8px 6px;
  font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase;
  color: #9a8256;
}
.list-heading:first-child { padding-top: 4px; }

.tag {
  display: inline-block; vertical-align: 2px; margin-left: 5px;
  padding: 1px 6px; border-radius: 8px;
  background: rgba(224, 181, 82, .16); border: 1px solid rgba(224, 181, 82, .45);
  color: var(--gold); font-size: 9px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
}

.item-icon { --size: 38px; }
.item.played .item-icon .medallion { filter: grayscale(.75) brightness(.65); }

.item-body { min-width: 0; }
.item-name { font-size: 15.5px; font-weight: 700; color: var(--parchment); }
.item.active .item-name { color: var(--gold-light); }
.item.played .item-name { text-decoration: line-through; }
.item-address { font-size: 12px; color: #9a8256; margin-top: 1px; }
.item-par {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--gold); margin-top: 3px;
}
.item-status { font-size: 12px; margin-top: 3px; }
.item-note { font-size: 12px; color: #8f7a55; font-style: italic; margin-top: 3px; }

.item-time {
  text-align: right; font-size: 13px; color: var(--gold);
  white-space: nowrap; line-height: 1.35;
}
.item-time small { display: block; font-size: 10.5px; color: #8b7549; }

.item-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.item-actions .btn { font-size: 11px; padding: 7px 11px; }

.fine-print {
  margin: 14px 6px 0; font-size: 10.5px; line-height: 1.5;
  color: #6f5f45; text-align: center;
}

/* ── Wide screens: the sheet becomes a side panel ────────────────────── */
@media (min-width: 620px) {
  .marker-label { max-width: 150px; }
  .sheet {
    left: auto; right: 0; top: 0; width: 400px; max-height: 100%;
    border-top: 0; border-left: 2px solid var(--gold-dark);
    border-radius: 16px 0 0 16px;
  }
  .sheet .handle { display: none; }
  .sheet .sheet-body { opacity: 1; max-height: none; pointer-events: auto; }
  .tools, .compass { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  .tools { right: 416px; }
}
