/* MTG Connections — dark daily puzzle, thumb-first. */
:root {
  --bg: #14101c; --panel: #1d1826; --panel-2: #262031; --line: #352d44;
  --ink: #f2eff7; --dim: #9c93ad; --accent: #a48fff; --warn: #f0a33c; --bad: #f87171;
  --d1: #d9b93f; --d2: #58b368; --d3: #58a0d8; --d4: #a06bc9;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans); min-height: 100vh; }

.topbar { display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem; }
.hub-link { color: var(--dim); text-decoration: none; font-size: .78rem; font-weight: 700; }
.app-title { font-weight: 800; letter-spacing: -.02em; }
.daynum { color: var(--accent); font-weight: 800; }
.streak { margin-left: auto; color: var(--warn); font-weight: 800; font-size: .9rem; }

main { max-width: 560px; margin: 0 auto; padding: 0 .8rem 3rem; }
.hint { color: var(--dim); font-size: .84rem; }

#solved { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .45rem; }
.band { border-radius: 12px; padding: .55rem .8rem; text-align: center; color: #14101c; }
.band b { display: block; font-size: .92rem; letter-spacing: -.01em; }
.band span { font-size: .78rem; opacity: .85; }
.band.d1 { background: var(--d1); } .band.d2 { background: var(--d2); }
.band.d3 { background: var(--d3); } .band.d4 { background: var(--d4); }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.tile {
  border: 2px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px;
  font: inherit; font-size: .68rem; font-weight: 700; line-height: 1.15; letter-spacing: -.01em;
  padding: 0 0 .3rem; cursor: pointer; word-break: break-word; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: .25rem; text-align: center;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tile img { width: 100%; aspect-ratio: 5/4; object-fit: cover; pointer-events: none; -webkit-touch-callout: none; }
.tile .tname { padding: 0 .25rem; }
.tile.sel img { opacity: .85; }
.tile.sel { background: var(--accent); border-color: var(--accent); color: #170f2b; }
.tile.sel .tname { font-weight: 800; }
.tile.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.controls { display: flex; align-items: center; gap: .5rem; margin: .9rem 0; }
.mistakes { flex: 1; color: var(--dim); font-size: .82rem; font-weight: 700; letter-spacing: .15em; }
.primary { border: none; border-radius: 12px; background: var(--accent); color: #170f2b; font: inherit; font-weight: 800; padding: .6rem 1.2rem; cursor: pointer; }
.primary:disabled { opacity: .4; }
.secondary { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; font: inherit; font-weight: 700; padding: .6rem .9rem; cursor: pointer; }

.toast { position: fixed; top: 3.4rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-weight: 800; border-radius: 99px; padding: .5rem 1.1rem; z-index: 50; font-size: .88rem; }
.toast.hidden { display: none; }

.result { text-align: center; margin-top: 1.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; }
.result h2 { margin: 0 0 .2rem; letter-spacing: -.02em; }
.result .sub { color: var(--dim); font-size: .9rem; margin-bottom: .7rem; }
.result .sub b { color: var(--warn); }
.share-grid { font-size: 1.15rem; letter-spacing: .12em; line-height: 1.45; margin: .4rem 0 .9rem; }
.hidden { display: none !important; }

.card-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 6, 18, .85); display: grid; place-items: center; padding: 1rem; cursor: pointer; }
.card-overlay.hidden { display: none; }
.card-overlay img { max-width: min(92vw, 340px); width: 100%; border-radius: 4.5%/3.5%; box-shadow: 0 14px 40px rgba(0, 0, 0, .6); }

@media (min-width: 700px) { .tile { font-size: .78rem; min-height: 72px; } }

/* ---- Mobile feel: bigger touch targets, autosizing names, no tap flash ---- */
.tile { transition: background .08s, border-color .08s; }
.tile:active { border-color: var(--accent); }
.tile.long { font-size: .62rem; }
.tile.vlong { font-size: .56rem; letter-spacing: 0; }
.controls .primary, .controls .secondary { min-height: 44px; touch-action: manipulation; }
@media (max-width: 380px) { .tile { min-height: 58px; font-size: .64rem; } .tile.long { font-size: .58rem; } .tile.vlong { font-size: .53rem; } }
@media (min-width: 700px) {
  .tile.long { font-size: .72rem; }
  .tile.vlong { font-size: .66rem; }
}

/* ---- Solved-group peek ---- */
.band { border: none; font: inherit; cursor: pointer; width: 100%; }
.band:active { filter: brightness(1.08); }
.quad { width: min(94vw, 620px); cursor: pointer; }
.quad-label { border-radius: 10px; padding: .45rem .8rem; text-align: center; font-weight: 800; color: #14101c; margin-bottom: .6rem; }
.quad-label.d1 { background: var(--d1); } .quad-label.d2 { background: var(--d2); }
.quad-label.d3 { background: var(--d3); } .quad-label.d4 { background: var(--d4); }
.quad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.quad-grid img { width: 100%; border-radius: 4.5%/3.5%; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
@media (min-width: 700px) { .quad { width: min(90vw, 760px); } .quad-grid { grid-template-columns: repeat(4, 1fr); } }
