/* Taltræf – styling. Mobile first, optimeret til iPhone/iPad. */

:root {
  --bg-1: #0d1024;
  --bg-2: #171a3a;
  --surface: rgba(255, 255, 255, .06);
  --surface-2: rgba(255, 255, 255, .10);
  --line: rgba(255, 255, 255, .12);
  --text: #eef1ff;
  --text-dim: rgba(238, 241, 255, .55);
  --tile: #2a3160;
  --tile-2: #232a52;
  --tile-text: #ffffff;
  --tile-empty: rgba(255, 255, 255, .045);
  --accent: #5b8cff;
  --accent-2: #8f6bff;
  --good: #3ddc97;
  --bad: #ff5d6c;
  --gold: #ffce4f;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

body.light {
  --bg-1: #eef1fb;
  --bg-2: #dfe5f7;
  --surface: rgba(23, 30, 70, .05);
  --surface-2: rgba(23, 30, 70, .09);
  --line: rgba(23, 30, 70, .14);
  --text: #1b2044;
  --text-dim: rgba(27, 32, 68, .6);
  --tile: #ffffff;
  --tile-2: #f0f3ff;
  --tile-text: #1b2044;
  --tile-empty: rgba(23, 30, 70, .06);
  --accent: #3a6dff;
  --accent-2: #7a4dff;
  --shadow: 0 10px 26px rgba(30, 40, 90, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 70%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- topbar ---------- */

.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
}

.stats {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
}

.stat-label {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-main .stat-value {
  font-size: 24px;
  background: linear-gradient(180deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-value.bump { animation: bump .32s ease; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.icon-btn:active { background: var(--surface-2); transform: scale(.95); }

/* Tilbage til forsiden på zydy.dk – et link stylet som de andre topbar-knapper */
.icon-btn.back { text-decoration: none; color: var(--text-dim); }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- brættet ---------- */

#boardWrap {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 10px 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#board {
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  container-type: inline-size;
  align-content: start;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 22%;
  display: grid;
  place-items: center;
  font-size: clamp(15px, 5.4cqi, 30px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--tile-text);
  background: linear-gradient(180deg, var(--tile), var(--tile-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 1px 2px rgba(0, 0, 0, .18);
  cursor: pointer;
  transition: transform .16s ease, opacity .18s ease, box-shadow .16s ease, background .16s ease;
  will-change: transform;
}

body.light .cell {
  box-shadow: inset 0 -2px 0 rgba(23, 30, 70, .07), 0 1px 3px rgba(30, 40, 90, .14);
}

.cell.empty {
  background: var(--tile-empty);
  box-shadow: none;
  color: transparent;
  cursor: default;
}

.cell.sel {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  transform: scale(1.06);
  box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgba(91, 140, 255, .45);
  z-index: 2;
}

.cell.cand::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(61, 220, 151, .75);
  animation: candpulse 1.4s ease-in-out infinite;
}

@keyframes candpulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

.cell.hint {
  animation: hintpulse .7s ease-in-out 4;
}

@keyframes hintpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 206, 79, 0); }
  50% { box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(255, 206, 79, .55); transform: scale(1.05); }
}

/* Tryk-respons allerede når fingeren rammer, før trækket afgøres. */
.cell.press {
  transform: scale(.92);
  transition-duration: .06s;
}

.cell.sel.press { transform: scale(1.0); }

.cell.bad { animation: shake .34s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.cell.fresh { animation: drop .28s cubic-bezier(.2, .9, .3, 1.2) both; }

@keyframes drop {
  from { transform: translateY(-14px) scale(.8); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Lag til point-popups og til kopier af ryddede felter. Ligger fast over hele
   skærmen, så animationer kan køre videre efter brættet er tegnet om – og så de
   ikke flytter sig når man ruller på en høj plade. */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.ghost {
  position: absolute;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--good), #23b57c);
  color: #04231a;
  will-change: transform, opacity;
}

.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 17px;
  color: var(--good);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  animation: rise 1s ease-out forwards;
  white-space: nowrap;
}

.floater.gold { color: var(--gold); font-size: 21px; }

@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ---------- værktøjslinje ---------- */

.toolbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
}

.tool {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tool:active { transform: scale(.97); background: var(--surface-2); }

.tool[disabled] { opacity: .38; }

.tool b { font-variant-numeric: tabular-nums; }

.tool-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 140, 255, .35);
}

.tool-primary[disabled] { box-shadow: none; }

.tool.nudge { animation: nudge 1.1s ease-in-out infinite; }

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ---------- modaler ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 18, .6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 30;
  animation: fade .2s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideup .26s cubic-bezier(.2, .9, .3, 1);
}

.sheet.center { text-align: center; }

@keyframes slideup {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.sheet h3 { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }

.rows { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.row-btn, .row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.row-btn:active { background: var(--surface-2); }
.row-btn.danger { color: var(--bad); }

/* iOS-agtig kontakt */
.row-toggle input {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background .18s ease;
  margin: 0;
  cursor: pointer;
}

.row-toggle input::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  transition: left .18s cubic-bezier(.3, .8, .4, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

.row-toggle input:checked {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.row-toggle input:checked::after { left: 22px; }

.btn {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active { transform: scale(.98); }
.btn.wide { display: block; width: 100%; margin-top: 12px; }

.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(91, 140, 255, .35);
}

.help { font-size: 15px; line-height: 1.5; color: var(--text); }
.help p { margin: 10px 0; }
.help ul { margin: 8px 0; padding-left: 20px; }
.help li { margin: 5px 0; }

.fineprint { font-size: 12.5px; line-height: 1.45; color: var(--text-dim); margin: 14px 0 0; }

.big {
  font-size: 30px;
  font-weight: 800;
  margin: 6px 0 0;
  background: linear-gradient(180deg, var(--gold), #ff9d4f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.burst { font-size: 46px; line-height: 1; margin-bottom: 6px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 50;
  max-width: 84vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(10, 14, 34, .92);
  border: 1px solid var(--line);
  color: #eef1ff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- store skærme (iPad) ---------- */

@media (min-width: 700px) {
  .stat-label { font-size: 11px; }
  .stat-value { font-size: 22px; }
  .stat-main .stat-value { font-size: 30px; }
  .stats { padding: 10px 16px; }
  #board { gap: 6px; max-width: 560px; }
  .tool { font-size: 14px; min-height: 62px; }
  .toolbar { max-width: 560px; margin: 0 auto; width: 100%; }
  .top { max-width: 620px; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
