/* ============================================================
   Klipparutmaningen: spelsidans utseende
   ============================================================ */
:root {
  --ink: #17301f;
  --cream: #f6f7ef;
  --yellow: #ffd34d;
  --accent: #d4401c;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#game {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- Raden överst ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 5px) calc(env(safe-area-inset-right, 0px) + 8px) 5px calc(env(safe-area-inset-left, 0px) + 8px);
  background: rgba(23, 48, 31, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.hud-stats {
  flex: 1;
  display: flex;
  justify-content: space-around;
  gap: 6px;
  min-width: 0;
}
.hud-stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.hud-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.7; }
.hud-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
#hud-pct { color: var(--yellow); }
.hud-btn {
  flex: none;
  width: 36px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--cream);
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}
.hud-btn svg { width: 20px; height: 20px; }
.hud-sound .ico-on { display: none; }
.hud-sound[aria-pressed="true"] { background: var(--yellow); color: var(--ink); }
.hud-sound[aria-pressed="true"] .ico-on { display: block; }
.hud-sound[aria-pressed="true"] .ico-off { display: none; }
@media (max-width: 350px) {
  .hud-label { display: none; }
  .hud-value { font-size: 15px; }
}

/* ---------- Delmål och tips ---------- */
#toast {
  position: absolute;
  left: 50%; top: 24%;
  transform: translate(-50%, 0) scale(0.6);
  padding: 12px 26px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(24px, 7vw, 40px);
  white-space: nowrap;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
#toast.show { animation: toast 1.7s cubic-bezier(.2, 1.4, .4, 1) both; }
#toast.small { font-size: clamp(17px, 4.6vw, 24px); }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -24px) scale(0.96); }
}

#hint {
  position: absolute;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16%);
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(23, 48, 31, 0.86);
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 4;
}
#hint.show { opacity: 1; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(-50%) translateY(-6px); } }

/* ---------- Start och resultat ---------- */
.overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: rgba(15, 34, 21, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.overlay[hidden] { display: none; }
.overlay.scrollable { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.panel {
  width: min(100%, 420px);
  padding: 26px 22px 22px;
  border-radius: 26px;
  background: var(--cream);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.panel-kicker { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #4f7a45; }
.panel h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: clamp(32px, 10vw, 44px); line-height: 1.02; letter-spacing: -0.01em; }
.panel-lede { margin: 10px 0 14px; font-size: 17px; line-height: 1.4; }
.howto { margin: 0 0 14px; padding: 12px 14px; list-style: none; text-align: left; font-size: 15px; line-height: 1.4; background: #e6efd6; border-radius: 16px; }
.howto li + li { margin-top: 8px; }
.howto-keys { display: none; }
@media (hover: hover) and (pointer: fine) {
  .howto-keys { display: list-item; }
  .howto-touch { display: none; }
}
.panel-best { margin: 0 0 14px; font-size: 15px; }

.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border: 0;
  border-radius: 16px;
  font: 700 19px/1.2 var(--sans);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s;
}
.btn:active { transform: translateY(2px) scale(0.99); }
.btn-play { background: var(--ink); color: #fff; box-shadow: 0 5px 0 #0a1a10; }
.btn-ghost { margin-top: 10px; min-height: 46px; padding: 10px; background: transparent; color: var(--ink); border: 2px solid rgba(23, 48, 31, 0.25); font-size: 16px; }
.btn-ghost[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow); }
.btn-light { background: #dfeccf; color: var(--ink); }
.btn-give { background: var(--accent); color: #fff; box-shadow: 0 5px 0 #9d2c10; }

.panel-result { padding-top: 18px; }
.record { display: inline-block; margin: 0 0 10px; padding: 6px 16px; border-radius: 999px; background: var(--yellow); font-weight: 700; font-size: 15px; }
#card-img {
  display: block;
  width: auto; height: auto;
  max-width: 100%;
  max-height: min(46vh, 430px);
  margin: 0 auto 12px;
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  background: var(--ink);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.share-status { min-height: 0; margin: 8px 0 0; font-size: 14px; line-height: 1.35; color: #3c6a35; }
.share-status:empty { display: none; }
.result-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.result-note { margin: 14px 0 0; font-size: 14.5px; line-height: 1.4; color: #3a5140; }

/* Liggande läge på låga skärmar: lägg kort och knappar sida vid sida */
@media (orientation: landscape) and (max-height: 560px) {
  .panel { width: min(100%, 640px); padding: 16px 18px; }
  .panel h1 { font-size: 30px; }
  .howto { font-size: 14px; }
  #card-img { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  #toast.show { animation: toast-plain 1.7s both; }
  #hint.show { animation: none; }
  .btn { transition: none; }
  @keyframes toast-plain { 0%, 100% { opacity: 0; transform: translate(-50%, 0); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } }
}
