:root { --bg: #111827; --panel: #1f2937; --panel-2: #374151; --border: #374151; --text: #f3f4f6; --muted: #9ca3af; --accent: #6366f1; --accent-hover: #4f46e5; --error: #f87171; }
body { font-family: system-ui, sans-serif; margin: 0; background: var(--bg); color: var(--text); }
input, button { font: inherit; border-radius: 6px; border: 1px solid var(--border); padding: 0.45rem 0.7rem; background: var(--panel); color: var(--text); }
input::placeholder { color: var(--muted); }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
button { cursor: pointer; background: var(--accent); border-color: var(--accent); color: #fff; }
button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: default; }
.layout { display: flex; align-items: flex-start; }
.sidebar { position: sticky; top: 0; width: 200px; flex: none; box-sizing: border-box; min-height: 100vh; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; background: var(--panel); border-right: 1px solid var(--border); }
.sidebar h1 { font-size: 1.2rem; margin: 0; color: #fff; }
.sidebar label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.sidebar a { padding: 0.4rem 0.6rem; border-radius: 6px; color: var(--muted); text-decoration: none; }
.sidebar a:hover { background: var(--panel-2); color: var(--text); }
.sidebar a[aria-current="page"] { background: var(--accent); color: #fff; }
main { flex: 1; min-width: 0; padding: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-top: 1rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; }
.card img { width: 100%; height: auto; display: block; border-radius: 4px; }
.card .noposter { background: var(--panel-2); color: var(--muted); height: 120px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.poster { position: relative; overflow: hidden; }
.poster .overview { display: none; position: absolute; inset: 0; overflow-y: auto; padding: 0.5rem; box-sizing: border-box; background: rgba(17, 24, 39, 0.92); color: #fff; font-size: 0.8rem; }
.poster:hover .overview, .poster:focus-within .overview, .poster:focus .overview { display: block; }
.meta { font-size: 0.85rem; color: var(--muted); }
#message { color: var(--error); min-height: 1.2em; }

/* Movie Lottery */
.lottery { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; margin-top: 1rem; }
.stage { --glow: 0; position: relative; box-sizing: border-box; width: 100%; max-width: 900px; padding: 1.5rem 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 0 calc(10px + 40px * var(--glow)) rgba(99, 102, 241, calc(0.2 + 0.5 * var(--glow))); }
.stage::before { content: ''; position: absolute; inset: 5px; border: 4px dotted #fbbf24; border-radius: 9px; pointer-events: none; animation: bulbs 1s steps(1) infinite; }
@keyframes bulbs { 50% { border-color: rgba(251, 191, 36, 0.3); } }
.stage.land { animation: shake 0.45s ease-in-out; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
#reel { min-height: 210px; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); }
#strip { position: relative; display: flex; gap: 20px; width: max-content; will-change: transform; }
.tile { flex: none; width: 140px; height: 210px; border-radius: 6px; overflow: hidden; background: var(--panel-2); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .noposter { height: 100%; box-sizing: border-box; padding: 0.5rem; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.85rem; color: var(--muted); }
.tile.hit { outline: 3px solid #fbbf24; box-shadow: 0 0 24px rgba(251, 191, 36, 0.8); }
#pointer { position: absolute; left: 50%; top: 4px; z-index: 1; width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-top: 20px solid #fbbf24; transform: translateX(-50%); transform-origin: 50% 0; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
#countdown { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-size: 5rem; font-weight: 700; color: #fff; text-shadow: 0 0 24px var(--accent); background: rgba(17, 24, 39, 0.6); border-radius: 12px; pointer-events: none; }
#countdown[hidden] { display: none; }
#spin { font-size: 1.1rem; padding: 0.6rem 1.8rem; }
#sound-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#lottery-result { position: relative; display: flex; justify-content: center; width: 100%; }
#lottery-result:not(:empty)::before { content: ''; position: absolute; inset: -1rem 0; background: radial-gradient(ellipse at 50% 40%, rgba(99, 102, 241, 0.35), transparent 65%); pointer-events: none; }
#lottery-result .card { position: relative; width: 260px; max-width: 100%; border: 2px solid var(--accent); box-shadow: 0 0 20px rgba(99, 102, 241, 0.5); }
.card.winner { animation: flip 0.7s ease-out; }
.card.winner.static { animation: none; }
@keyframes flip { from { transform: perspective(800px) rotateY(90deg) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.ribbon { position: absolute; top: -0.6rem; right: -0.6rem; z-index: 3; padding: 0.2rem 0.7rem; border-radius: 999px; background: #fbbf24; color: #111827; font-weight: 700; font-size: 0.8rem; transform: rotate(6deg); }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 8; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  .stage::before, .stage.land { animation: none; }
  .card.winner { animation: fade 0.3s; }
}
@media (max-width: 639px) {
  .layout { flex-direction: column; align-items: stretch; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .sidebar a { padding: 0.3rem 0.5rem; }
  #reel { min-height: 150px; }
  .tile { width: 100px; height: 150px; }
  .sidebar { position: static; width: auto; min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
}
.badges { position: absolute; top: 0.4rem; left: 0.4rem; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; pointer-events: none; }
.badge { padding: 0.1rem 0.5rem; border-radius: 999px; background: rgba(22, 101, 52, 0.95); color: #fff; font-size: 0.75rem; }
.badge.watched { background: rgba(30, 64, 175, 0.95); }
.poster .overview { z-index: 2; }
.rating { font-size: 0.85rem; color: #fbbf24; }
button.secondary { background: var(--panel-2); border-color: var(--border); }
button.in-list { background: var(--panel-2); border-color: var(--border); color: var(--muted); }
#toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 10; max-width: 320px; padding: 0.6rem 0.9rem; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); animation: toast-in 0.2s ease-out; }
#toast[hidden] { display: none; }
#toast.ok { border-color: #22c55e; }
#toast.warn { border-color: #f59e0b; }
#toast.err { border-color: var(--error); }
@keyframes toast-in { from { transform: translateY(1rem); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #toast { animation: none; } }

.card strong a { color: var(--text); text-decoration: none; }
.card strong a:hover, .card strong a:focus-visible { color: var(--accent); text-decoration: underline; }
.card a.seerr-btn { display: block; text-align: center; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem; text-decoration: none; font-size: 0.9rem; }
.card a.seerr-btn:hover, .card a.seerr-btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.nick-hint { font-size: 0.75rem; color: var(--muted); margin-top: -0.4rem; }
body.no-nick .nick-hint { color: var(--error); }
input[aria-invalid="true"] { border-color: var(--error); }
body.no-nick .card button:not(:disabled), body.no-nick .results button:not(:disabled) { opacity: 0.55; cursor: not-allowed; }
.welcome { background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; max-width: 480px; }
.welcome h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.welcome[hidden] { display: none; }
.pulse { animation: pulse 0.6s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.8); } 100% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
@media (max-width: 639px) { .nick-hint { flex-basis: 100%; margin-top: 0; } }
.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.head h2 { margin: 0.5rem 0; }
.count { color: var(--muted); font-weight: normal; font-size: 0.9em; }
.sort { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.sort select { font: inherit; border-radius: 6px; border: 1px solid var(--border); padding: 0.3rem 0.5rem; background: var(--panel); color: var(--text); }
.empty { color: var(--muted); }
.empty a { color: var(--accent); }
#toast button { margin-left: 0.75rem; padding: 0.15rem 0.6rem; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 0.5rem 0; margin-bottom: 0.5rem; }
#search-form { position: relative; max-width: 640px; }
#q { box-sizing: border-box; width: 100%; padding-right: 2.2rem; }
#q-clear { position: absolute; right: 0.25rem; top: 50%; transform: translateY(-50%); padding: 0 0.5rem; line-height: 1.6; background: transparent; border-color: transparent; color: var(--muted); font-size: 1.2rem; }
#q-clear:hover:not(:disabled) { background: transparent; border-color: transparent; color: var(--text); }
#q-clear[hidden] { display: none; }
.results { position: absolute; left: 0; top: calc(100% - 0.25rem); z-index: 6; width: 100%; max-width: 640px; box-sizing: border-box; max-height: min(60vh, 480px); overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.results[hidden] { display: none; }
.result { display: flex; gap: 0.75rem; padding: 0.6rem; border-bottom: 1px solid var(--border); }
.result:last-child { border-bottom: 0; }
.result.active { background: var(--panel-2); }
.result .thumb { flex: none; width: 70px; }
.result .thumb img { width: 100%; height: auto; display: block; border-radius: 4px; }
.result .noposter { background: var(--panel-2); color: var(--muted); width: 70px; height: 105px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.75rem; border-radius: 4px; }
.result .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.result strong a { color: var(--text); text-decoration: none; }
.result strong a:hover, .result strong a:focus-visible { color: var(--accent); text-decoration: underline; }
.result .badges { position: static; flex-direction: row; flex-wrap: wrap; }
.result .ov { font-size: 0.8rem; color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.result .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }
.result .actions button { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.result a.seerr-btn { display: inline-block; text-align: center; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.6rem; text-decoration: none; font-size: 0.85rem; }
.result a.seerr-btn:hover, .result a.seerr-btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.result-msg { padding: 0.75rem; color: var(--muted); }
@media (max-width: 639px) {
  .results { max-height: 70vh; }
  .result .thumb { width: 56px; }
  .result .noposter { width: 56px; height: 84px; }
  .result .ov { -webkit-line-clamp: 2; line-clamp: 2; }
}
