/* Spot the Difference — cozy travel-postcard UI: cream paper, ink outlines, stamp edges. Fully responsive
   (side-by-side pictures in landscape, stacked in portrait). */
:root { --ink: #33314a; --paper: #fff6e9; --paper2: #f6e7cf; --red: #e8505b; --blue: #3a86c8; --green: #3fae6a; --sun: #f7c948; --sky: #bfe3f2; --shadow: rgba(51,49,74,.25); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3e3c6; color: var(--ink);
  font-family: 'Baloo 2', 'Nunito', system-ui, 'Noto Sans', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { position: fixed; inset: 0; overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #fff3dc 0, transparent 50%), repeating-linear-gradient(45deg, #f1dfbf 0 14px, #f4e4c7 14px 28px); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0 } 70% { transform: scale(1.05); opacity: 1 } 100% { transform: scale(1) } }
@keyframes wob { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(1.5deg) } }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-4px) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-6px) } 40% { transform: translateX(5px) } 60% { transform: translateX(-3px) } 80% { transform: translateX(2px) } }
@keyframes snap { 0% { transform: scale(2.4) rotate(-10deg); opacity: 0 } 40% { transform: scale(1) rotate(-6deg); opacity: 1 } 100% { transform: scale(1) rotate(-6deg); opacity: 1 } }
@keyframes stampIn { 0% { transform: scale(3) rotate(25deg); opacity: 0 } 60% { transform: scale(.9) rotate(-8deg); opacity: 1 } 100% { transform: scale(1) rotate(-8deg) } }
@keyframes starIn { 0% { transform: scale(0) rotate(-90deg) } 70% { transform: scale(1.4) rotate(10deg) } 100% { transform: scale(1) } }

/* ---------------- buttons */
.btn { border: 3px solid var(--ink); border-radius: 16px; padding: 6px 16px 8px; font-weight: 800; font-size: 17px; cursor: pointer;
  background: #fff; box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.1; }
.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.red { background: var(--red); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.white { background: #fff; }
.btn.big { font-size: 24px; padding: 8px 26px 10px; border-radius: 20px; }
.btn.small { font-size: 16px; padding: 2px 12px 4px; }
.btn.toggle { min-width: 84px; }
.btn.toggle.on { background: var(--green); color: #fff; }

/* ---------------- overlays & panels */
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(51,49,74,.45); animation: fade .2s ease; padding: 12px; z-index: 20; }
.panel { background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); padding: 14px 20px 18px;
  width: min(460px, 100%); max-height: 100%; overflow: auto; animation: pop .25s ease; text-align: center; }
.panel.wide { width: min(1000px, 100%); height: min(680px, 100%); display: flex; flex-direction: column; text-align: left; }
.panel h2 { margin: 2px 0 8px; font-size: 28px; line-height: 1.1; }
.phead { display: flex; align-items: center; gap: 12px; }
.phead h2 { flex: 1; margin: 0; }
.stars-total { font-weight: 800; font-size: 18px; white-space: nowrap; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.actions.col { flex-direction: column; align-items: stretch; }
.quip { font-size: 17px; font-weight: 700; margin: 6px 0; font-style: italic; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 2px dashed var(--paper2); font-weight: 800; font-size: 18px; text-align: left; }
.setrow small { display: block; font-size: 13px; font-weight: 700; opacity: .7; }
.setrow select { font: inherit; font-size: 16px; border: 3px solid var(--ink); border-radius: 12px; padding: 2px 8px; background: #fff; }
.howto { text-align: left; font-size: 17px; font-weight: 700; padding-left: 22px; margin: 6px 0; }
.howto li { margin: 6px 0; }

/* ---------------- loading */
#loading { background: var(--paper); }
.loader { text-align: center; font-size: 22px; font-weight: 800; }
.spin { font-size: 56px; animation: bob .6s ease-in-out infinite; }
.bar { width: 240px; height: 14px; border: 3px solid var(--ink); background: #fff; overflow: hidden; margin: 6px auto 0; border-radius: 10px; }
.bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s; }

/* ---------------- menu */
#menu { background: rgba(51,49,74,.25); }
.menu-card { position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 10px 0 var(--ink);
  width: min(620px, 100%); padding: 18px 24px 20px; text-align: center; animation: pop .3s ease; max-height: 100%; overflow: auto; }
.menu-card::before { content: ''; position: absolute; inset: 8px; border: 3px dashed var(--paper2); border-radius: 20px; pointer-events: none; }
#menu-pip { width: 120px; height: 120px; display: block; margin: -6px auto -4px; animation: bob 2.4s ease-in-out infinite; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .9; animation: wob 5s ease-in-out infinite; }
.logo .l1 { font-size: 30px; font-weight: 800; color: var(--blue); }
.logo .l2 { font-size: clamp(40px, 9vw, 64px); font-weight: 800; color: var(--red); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); letter-spacing: 1px; }
.logo .l3 { margin-top: 8px; font-size: 18px; font-weight: 800; background: var(--sun); border: 3px solid var(--ink); padding: 0 14px; border-radius: 14px; transform: rotate(-2deg); }
.tagline { font-weight: 700; font-size: 16px; margin: 10px 0 6px; }
.menu-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
#btn-play { flex-direction: column; min-width: 190px; }
#btn-play small, .daily small { font-size: 13px; font-weight: 700; opacity: .92; }
.daily { flex-direction: column; min-width: 190px; }
.daily b { font-size: 19px; }
.menu-stats { margin: 10px 0 4px; font-weight: 800; font-size: 16px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.menu-stats span { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 0 10px; }
.menu-nav { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.menu-nav .btn { font-size: 15px; padding: 4px 12px 6px; }

/* ---------------- level select */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.chip { border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 2px 10px 3px; font-weight: 800; font-size: 15px; cursor: pointer; display: flex; gap: 5px; align-items: center; }
.chip.on { background: var(--ink); color: #fff; }
.chip.locked { opacity: .55; }
.chdesc { font-weight: 700; font-size: 15px; margin: 2px 0 8px; min-height: 22px; }
.grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 4px 4px 10px; align-content: start; }
.pc { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 6px 6px 4px; cursor: pointer; box-shadow: 0 4px 0 var(--shadow);
  transition: transform .12s; }
.pc:hover { transform: translateY(-3px) rotate(-1deg); }
.pc img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; border-radius: 4px; background: var(--paper2); }
.pc .pn { position: absolute; left: 10px; top: 10px; background: var(--ink); color: #fff; font-weight: 800; border-radius: 10px; padding: 0 8px; font-size: 14px; }
.pc .pname { font-weight: 800; font-size: 14px; margin-top: 4px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc .pstars { color: #d9c9a8; font-size: 16px; letter-spacing: 1px; }
.pc .pstars b { color: #f2a900; font-weight: 400; }
.pc.locked { cursor: not-allowed; }
.pc.locked img { filter: grayscale(1) blur(3px) brightness(1.1); }
.pc.locked::after { content: '🔒'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.pc.next { outline: 4px solid var(--sun); animation: bob 1.6s ease-in-out infinite; }
.pc .pnew { position: absolute; right: 8px; top: 8px; background: var(--red); color: #fff; font-weight: 800; font-size: 12px; border-radius: 8px; padding: 0 6px; border: 2px solid var(--ink); }

/* ---------------- album */
.stamps { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.stampc { width: 96px; height: 106px; background: #fff; border: 2px dashed var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; text-align: center; line-height: 1.1; padding: 4px; }
.stampc .se { font-size: 38px; }
.stampc.got { border: 3px solid var(--red); color: var(--red); transform: rotate(-4deg); background: #fff0f0; }
.stampc:not(.got) .se { filter: grayscale(1); opacity: .35; }
.album .pc.empty img { filter: grayscale(1) contrast(.3) brightness(1.4); }

.pcard { width: min(760px, 100%); display: flex; background: #fff; border: 4px solid var(--ink); border-radius: 12px; box-shadow: 0 8px 0 var(--ink); overflow: hidden; animation: pop .25s ease; }
.pcard img { width: 58%; aspect-ratio: 3/2; object-fit: cover; display: block; }
.pc-back { flex: 1; padding: 12px 14px; position: relative; border-left: 3px dashed var(--paper2); text-align: left; }
.pc-back h3 { margin: 0 64px 6px 0; font-size: 22px; line-height: 1.1; }
.pc-back p { font-size: 16px; font-weight: 700; font-style: italic; margin: 6px 0; }
.pc-stamp { position: absolute; right: 10px; top: 10px; width: 56px; height: 62px; border: 3px dashed var(--red); display: flex; align-items: center; justify-content: center; font-size: 30px; transform: rotate(6deg); }
.pc-meta { font-weight: 800; font-size: 14px; opacity: .8; }

/* ---------------- result */
.result { position: relative; overflow: visible; }
.snap { position: absolute; left: -10px; top: -26px; font-size: 40px; font-weight: 800; color: #fff; background: var(--red); border: 4px solid var(--ink); border-radius: 14px; padding: 0 12px; animation: snap .5s ease both; z-index: 2; }
.rcard { position: relative; margin: 10px auto 6px; width: min(300px, 80%); background: #fff; padding: 8px 8px 22px; border: 3px solid var(--ink); transform: rotate(2deg); box-shadow: 0 6px 0 var(--shadow); }
.rcard img { width: 100%; display: block; aspect-ratio: 3/2; object-fit: cover; }
.rstamp { position: absolute; right: -16px; bottom: -14px; font-size: 16px; font-weight: 800; color: var(--red); border: 3px solid var(--red); border-radius: 50%; width: 84px; height: 84px; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1; background: rgba(255,255,255,.85); animation: stampIn .5s .5s ease both; padding: 4px; }
.rstars { font-size: 46px; line-height: 1; color: #d9c9a8; letter-spacing: 4px; }
.rstars span.on { color: #f2a900; display: inline-block; animation: starIn .45s ease both; -webkit-text-stroke: 2px var(--ink); }
.rstats { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-weight: 800; font-size: 16px; max-width: 300px; margin: 4px auto; text-align: left; }
.rstats b { text-align: right; }
.rnew { font-weight: 800; color: var(--green); font-size: 16px; }

/* ---------------- HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; z-index: 10;
  padding-top: max(6px, env(safe-area-inset-top)); pointer-events: none; }
#hud > * { pointer-events: auto; }
.hbtn { border: 3px solid var(--ink); background: #fff; border-radius: 14px; height: 42px; min-width: 42px; font-weight: 800; font-size: 17px; cursor: pointer; box-shadow: 0 3px 0 var(--ink); position: relative; }
.hbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.hbtn.hint { background: var(--sun); font-size: 20px; padding: 0 8px; }
.hbtn.hint i { position: absolute; right: -8px; top: -8px; background: var(--red); color: #fff; font-style: normal; font-size: 13px; border: 2px solid var(--ink); border-radius: 10px; padding: 0 5px; line-height: 1.3; }
.hbtn.hint.pulse { animation: bob .6s ease-in-out infinite; }
.hinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 0 10px 2px; box-shadow: 0 3px 0 var(--ink); }
.htitle { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hdots { display: flex; gap: 4px; line-height: 1; }
.hdots i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; display: inline-block; }
.hdots i.on { background: var(--green); animation: pop .3s ease; }
.hright { display: flex; gap: 8px; align-items: center; }
.htime { background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; height: 42px; padding: 0 10px; display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 19px; box-shadow: 0 3px 0 var(--ink); min-width: 86px; justify-content: center; }
.htime.low { background: #ffd6d6; animation: shake .5s ease infinite; }
.htime.off { display: none; }
.hhearts { font-size: 17px; letter-spacing: -2px; white-space: nowrap; }
.hhearts .gone { filter: grayscale(1); opacity: .3; }
.hhearts.hit { animation: shake .35s ease; }

#zoombar { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.zbtn { width: 44px; height: 44px; border: 3px solid var(--ink); background: #fff; border-radius: 50%; font-size: 22px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--ink); line-height: 1; }

.narr { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: flex-end; gap: 4px; z-index: 11; pointer-events: none; max-width: min(460px, calc(100% - 70px)); animation: pop .25s ease; }
.narr canvas { width: 64px; height: 64px; flex: none; animation: bob 1.2s ease-in-out infinite; }
.narr p { margin: 0 0 18px; background: #fff; border: 3px solid var(--ink); border-radius: 16px 16px 16px 4px; padding: 4px 12px 6px; font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 var(--shadow); }
.toast { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 800; padding: 4px 16px 6px; border-radius: 14px; z-index: 12; animation: pop .2s ease; white-space: nowrap; }

#zoombar.inhud { position: static; flex-direction: row; gap: 6px; padding: 0; }
#zoombar.inhud .zbtn { width: 42px; height: 42px; border-radius: 14px; font-size: 20px; }
@media (max-height: 520px) {
  .narr canvas { width: 44px; height: 44px; }
  .narr { max-width: min(380px, 46%); }
  .narr p { font-size: 13px; margin-bottom: 10px; padding: 3px 10px 4px; }
}
@media (max-width: 700px) {
  #zoombar.inhud { gap: 4px; }
  #zoombar.inhud .zbtn { width: 38px; height: 38px; font-size: 18px; }
  .hright { gap: 5px; }
  #hud { gap: 5px; }
}
@media (max-width: 560px) {
  .hbtn { height: 38px; min-width: 38px; }
  .htime { height: 38px; font-size: 16px; min-width: 70px; }
  .hhearts { font-size: 13px; }
  .panel.wide { height: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .pcard { flex-direction: column; }
  .pcard img { width: 100%; }
  .pc-back { border-left: 0; border-top: 3px dashed var(--paper2); }
}
@media (max-height: 520px) {
  #menu-pip { display: none; }
  .menu-card { padding: 10px 18px; }
  .tagline { display: none; }
  .rcard { width: 200px; }
  .rstars { font-size: 34px; }
}
.after { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 10px; z-index: 12; animation: pop .25s ease; }
/* time-of-day thumbnails match the in-game colour grade */
.v-dusk img, img.v-dusk { filter: sepia(.35) saturate(1.35) hue-rotate(-12deg) brightness(.97); }
.v-night img, img.v-night { filter: brightness(.5) saturate(.9) sepia(.2) hue-rotate(190deg) contrast(1.1); }
.chip.soon { border-style: dashed; }
.stampc.soon { opacity: .6; border-style: dotted; }
.stampc small { display: block; font-size: 10px; opacity: .8; }
/* phones & tablets: comfortable 44 px touch targets (older players) */
@media (pointer: coarse) {
  .menu-nav .btn, .btn.small, .chip, .btn.toggle, .setrow select { min-height: 44px; }
  .btn.small { min-width: 44px; }
}
/* six cities × three visits = 18 trips: on small screens the trip chips scroll sideways in one row */
.chips { position: relative; }
@media (max-width: 700px), (max-height: 500px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .chip { flex: none; white-space: nowrap; }
}
