/* Tile Rush · Go Daily look: bold ink outlines, pop shadows, Baloo 2 headings. Colours come from themes.css. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--background); color: var(--foreground);
  font: 500 16px/1.4 Nunito, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
h1, h2, h3, .display { font-family: "Baloo 2", Nunito, system-ui, sans-serif; line-height: 1.1; margin: 0; }
button, input, select { font: inherit; color: inherit; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.page { max-width: 520px; width: 100%; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 2px solid var(--foreground); border-radius: 18px; padding: 18px; box-shadow: 0 4px 0 var(--shadow); }
.muted { color: var(--muted-foreground); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  appearance: none; border: 2px solid var(--foreground); border-radius: 14px; padding: 12px 18px; min-height: 48px;
  background: var(--card); color: var(--foreground); font-weight: 800; box-shadow: 0 3px 0 var(--foreground);
  cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--foreground); }
.btn.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.sun { background: var(--sun); color: var(--sun-foreground); }
.btn.big { font-family: "Baloo 2", sans-serif; font-size: 24px; padding: 8px 22px; min-height: 58px; }
.btn:disabled { opacity: 0.45; box-shadow: none; transform: none; cursor: default; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; box-shadow: 0 2px 0 var(--foreground); }
.link { background: none; border: 0; color: var(--primary); font-weight: 800; padding: 8px; cursor: pointer; }
html[data-mode="dark"] .link, html:not([data-mode="light"]) .link { color: var(--accent); }
input.field {
  width: 100%; border: 2px solid var(--foreground); border-radius: 14px; padding: 12px 14px; min-height: 50px;
  background: var(--background); font-size: 18px; font-weight: 700;
}
input.code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-family: "Baloo 2", sans-serif; font-size: 24px; }
label.lbl { font-weight: 800; font-size: 14px; }
.error { color: var(--destructive); font-weight: 700; min-height: 1.4em; }

/* Home */
.hero { text-align: center; padding-top: 8px; }
.hero h1 { font-size: 44px; color: var(--primary); }
html[data-mode="dark"] .hero h1 { color: var(--foreground); }
@media (prefers-color-scheme: dark) { html:not([data-mode="light"]) .hero h1 { color: var(--foreground); } }
.hero-tiles { display: flex; justify-content: center; gap: 6px; margin: 10px 0 6px; }
.hero-tiles .tile { position: static; width: 44px; height: 44px; font-size: 26px; }
.howto ol { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin: 6px 0; }
.foot { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 14px; }
.foot select { border: 2px solid var(--border); border-radius: 10px; background: var(--card); padding: 6px; }

/* Lobby */
.code-big { font-family: "Baloo 2", sans-serif; font-size: 46px; letter-spacing: 0.18em; text-align: center; margin: 4px 0; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 12px; background: var(--background); font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--leaf); flex: none; }
.dot.away { background: var(--muted-foreground); opacity: 0.5; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--secondary); color: var(--foreground); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); }

/* Game */
.game { height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto auto; max-width: 720px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 6px; }
.topbar h2 { font-size: 22px; color: var(--primary); }
.pool { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 18px; padding: 2px 12px; border: 2px solid var(--foreground); border-radius: 99px; background: var(--sun); color: var(--sun-foreground); white-space: nowrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 99px; border: 2px solid var(--border); background: var(--card); white-space: nowrap; }
.chip.me { border-color: var(--primary); }
.chip.out { text-decoration: line-through; opacity: 0.55; }
.board {
  position: relative; overflow: hidden; touch-action: none; margin: 0 8px; border-radius: 16px;
  border: 2px solid var(--foreground); background-color: var(--card);
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  user-select: none; -webkit-user-select: none;
}
.plane { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.board .hint { position: absolute; inset: auto 0 12px 0; text-align: center; color: var(--muted-foreground); font-weight: 800; pointer-events: none; }
.drop { position: absolute; width: 46px; height: 46px; border: 3px dashed var(--primary); border-radius: 9px; pointer-events: none; }
.tile {
  position: absolute; width: 44px; height: 44px; display: grid; place-items: center;
  background: #FFF6E5; color: #2A1457; border: 2px solid #2A1457; border-radius: 9px; box-shadow: 0 3px 0 #2A1457;
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 27px; line-height: 1; padding-top: 3px;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.tile.bad { background: #FFC9C9; border-color: #C8102E; color: #8A0018; box-shadow: 0 3px 0 #C8102E; }
.tile.loose { border-style: dashed; }
.tile.new { animation: glow 1.2s ease-in-out 3; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px var(--sun), 0 3px 0 #2A1457; } }
.tile.ghost { position: fixed; z-index: 50; pointer-events: none; transform: scale(1.12); opacity: 0.95; }
.tile.lifted { opacity: 0.25; }
.rack { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; min-height: 64px; max-height: 32vh; overflow-y: auto; align-content: flex-start; }
.rack .tile { position: relative; }
.rack.empty::before { content: attr(data-empty); color: var(--muted-foreground); font-weight: 800; margin: auto; }
.status { padding: 0 12px; font-weight: 800; font-size: 14px; min-height: 1.4em; }
.status.bad { color: var(--destructive); }
.status.good { color: var(--leaf); }
html[data-mode="dark"] .status.good { color: #5EE0B4; }
.actions { display: flex; gap: 8px; align-items: stretch; padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }
.swapzone { flex: none; width: 78px; border: 2px dashed var(--foreground); border-radius: 14px; display: grid; place-items: center; text-align: center; font-size: 12px; font-weight: 800; line-height: 1.1; padding: 4px; }
.swapzone.hot { background: var(--accent); color: var(--accent-foreground); border-style: solid; }
.swapzone.off { opacity: 0.4; }
.actions .big { flex: 1; }
.outnote { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in oklab, var(--background) 70%, transparent); font-weight: 800; text-align: center; padding: 20px; }

/* Summary */
.winner { text-align: center; }
.winner .emoji { font-size: 54px; }
.mini { position: relative; margin: 10px auto 0; }
.mini .tile { width: 26px; height: 26px; font-size: 16px; border-radius: 6px; box-shadow: 0 2px 0 #2A1457; cursor: default; }
.scores { width: 100%; border-collapse: collapse; }
.scores td { padding: 8px 4px; border-bottom: 1px solid var(--border); font-weight: 800; }
.scores td:last-child { text-align: right; font-family: "Baloo 2", sans-serif; font-size: 20px; }

/* Toast + modal */
#toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -150%); transition: transform 0.25s; z-index: 60;
  background: var(--foreground); color: var(--background); padding: 10px 16px; border-radius: 14px; font-weight: 800; max-width: 92vw; text-align: center; }
#toast.show { transform: translate(-50%, 0); }
#modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 8, 40, 0.5); padding: 16px; }
#modal[hidden] { display: none; }
#modal .card { max-width: 380px; width: 100%; }
