/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg:           #f7f4ef;
  --surface:      #ffffff;
  --surface2:     #f0ece6;
  --text:         #1a1a2e;
  --text-muted:   #706c80;
  --accent:       #e84040;
  --accent-dark:  #c82828;
  --accent-rgb:   232, 64, 64;
  --border:       #e0dbd3;
  --shadow-sm:    0 2px 8px rgba(0,0,0,.07);
  --shadow-md:    0 6px 24px rgba(0,0,0,.10);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.13);
  --radius:       14px;
  --radius-sm:    8px;
  --radius-xs:    5px;
  --font:         system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --dur:          .18s;
  --header-h:     60px;
  --panel-w:      300px;
}

[data-theme="dark"] {
  --bg:          #111111;
  --surface:     #1c1c1c;
  --surface2:    #252525;
  --text:        #edeae4;
  --text-muted:  #888080;
  --accent:      #e84040;
  --border:      #2e2e2e;
  --shadow-sm:   0 2px 8px rgba(0,0,0,.35);
  --shadow-md:   0 6px 24px rgba(0,0,0,.45);
  --shadow-lg:   0 16px 48px rgba(0,0,0,.55);
}

[data-theme="midnight"] {
  --bg:          #090d1a;
  --surface:     #0e1628;
  --surface2:    #152040;
  --text:        #e4e8f8;
  --text-muted:  #7986cc;
  --accent:      #6c63ff;
  --accent-dark: #5548e0;
  --accent-rgb:  108,99,255;
  --border:      #1c2a50;
  --shadow-sm:   0 2px 8px rgba(0,0,0,.5);
  --shadow-md:   0 6px 24px rgba(108,99,255,.2);
  --shadow-lg:   0 16px 48px rgba(108,99,255,.25);
}

[data-theme="neon"] {
  --bg:          #060606;
  --surface:     #0d0d0d;
  --surface2:    #141414;
  --text:        #f0f0f0;
  --text-muted:  #00cc70;
  --accent:      #00ff88;
  --accent-dark: #00cc6a;
  --accent-rgb:  0,255,136;
  --border:      #0a1a0f;
  --shadow-sm:   0 2px 8px rgba(0,255,136,.1);
  --shadow-md:   0 6px 24px rgba(0,255,136,.18);
  --shadow-lg:   0 16px 48px rgba(0,255,136,.22);
}

[data-theme="pastel"] {
  --bg:          #fdf6fc;
  --surface:     #ffffff;
  --surface2:    #f5e8f8;
  --text:        #2d1b69;
  --text-muted:  #9b7ec8;
  --accent:      #b45bff;
  --accent-dark: #9640e6;
  --accent-rgb:  180,91,255;
  --border:      #eed8f8;
  --shadow-sm:   0 2px 8px rgba(180,91,255,.08);
  --shadow-md:   0 6px 24px rgba(180,91,255,.14);
  --shadow-lg:   0 16px 48px rgba(180,91,255,.18);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  transition: background var(--dur), color var(--dur);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, textarea { font-family: var(--font); }
img { max-width: 100%; }

.skip-link {
  position: absolute; left: -999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: 12px; top: 12px;
  width: auto; height: auto;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: var(--radius-sm);
  z-index: 9999; font-weight: 600;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background var(--dur), border-color var(--dur);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1300px; margin: 0 auto;
  padding: 0 20px; height: var(--header-h);
  gap: 12px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.2rem; font-weight: 700;
  color: var(--text); text-decoration: none;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; opacity: .85; }
.logo-icon { width: 32px; height: 32px; flex-shrink: 0; }
.logo-accent { color: var(--accent); }

.header-controls {
  display: flex; align-items: center; gap: 6px;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--dur), color var(--dur);
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Theme cycle button — small dot with accent colour, no modal */
.theme-cycle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  transition: background var(--dur), transform .12s;
}
.theme-cycle-btn:hover  { background: var(--surface2); transform: scale(1.15); }
.theme-cycle-btn:active { transform: scale(.9); }
.theme-cycle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#themeLabel {
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

/* Language selector */
.lang-selector { position: relative; }

.lang-btn {
  display: flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .875rem; font-weight: 600;
  transition: background var(--dur), color var(--dur);
}
.lang-btn:hover { background: var(--surface2); color: var(--text); }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lang-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  overflow: hidden;
  z-index: 200;
  opacity: 0; transform: translateY(-6px) scale(.97);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.lang-dropdown.open {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
.lang-opt {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  font-size: .875rem; font-weight: 500;
  color: var(--text);
  transition: background var(--dur);
  text-align: left;
}
.lang-opt:hover { background: var(--surface2); }
.lang-opt.active { color: var(--accent); font-weight: 700; }

/* Ad slots */
.ad-wrap { display: flex; justify-content: center; align-items: center; }
.ad-top { min-height: 50px; background: var(--surface2); border-top: 1px solid var(--border); }
.ad-mid { min-height: 90px; margin-top: 20px; }
.ad-bottom { min-height: 90px; background: var(--surface2); border-top: 1px solid var(--border); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  text-align: center;
  padding: 40px 20px 24px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ============================================================
   APP GRID (3-column layout)
   ============================================================ */
.app-grid {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr var(--panel-w);
  grid-template-areas: "options wheel history";
  gap: 20px;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px 40px;
  align-items: start;
}

@media (max-width: 1100px) {
  :root { --panel-w: 260px; }
}

@media (max-width: 900px) {
  .app-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "wheel  wheel"
      "options history";
  }
}

@media (max-width: 600px) {
  .app-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "wheel"
      "options"
      "history";
    gap: 14px;
    padding: 0 12px 32px;
  }
  .hero { padding: 24px 12px 16px; }
}

.options-panel { grid-area: options; }
.wheel-area    { grid-area: wheel; }
.history-panel { grid-area: history; }

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur), border-color var(--dur);
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title {
  font-size: 1rem; font-weight: 700;
  letter-spacing: -.01em;
}

/* ============================================================
   OPTION INPUT
   ============================================================ */
.add-row {
  display: flex; gap: 8px; margin-bottom: 10px;
}

.text-input {
  flex: 1; min-width: 0;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--dur), background var(--dur);
}
.text-input::placeholder { color: var(--text-muted); }
.text-input:focus { border-color: var(--accent); }

.add-btn {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  transition: background var(--dur), transform .1s;
}
.add-btn:hover { background: var(--accent-dark); }
.add-btn:active { transform: scale(.93); }

.action-row {
  display: flex; gap: 8px; margin-bottom: 10px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .85rem; font-weight: 500;
  background: transparent;
  transition: border-color var(--dur), color var(--dur), background var(--dur);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),.04); }
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600;
  transition: background var(--dur), transform .1s;
}
.primary-btn:hover { background: var(--accent-dark); }
.primary-btn:active { transform: scale(.96); }

.sm-btn { padding: 7px 12px; font-size: .8rem; }
.flex-1 { flex: 1; }

/* ============================================================
   OPTIONS INPUT (textarea — primary input)
   ============================================================ */
.bulk-ta {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem; resize: vertical;
  outline: none; font-family: var(--font);
  transition: border-color var(--dur), background var(--dur);
  margin-bottom: 8px;
}
.bulk-ta:focus { border-color: var(--accent); }
.bulk-ta::placeholder { color: var(--text-muted); }

.options-ta-main { min-height: 100px; }

.options-actions {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}

/* ============================================================
   OPTIONS LIST
   ============================================================ */
.options-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 320px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  margin-bottom: 8px;
}
.options-list::-webkit-scrollbar { width: 4px; }
.options-list::-webkit-scrollbar-track { background: transparent; }
.options-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.option-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  font-size: .875rem;
  animation: fadeInUp .15s ease;
  transition: background var(--dur);
}
.option-item:hover { background: var(--border); }
@keyframes fadeInUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

.option-color {
  width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}
.option-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.option-delete {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--dur), background var(--dur), color var(--dur);
}
.option-item:hover .option-delete { opacity: 1; }
.option-delete:hover { background: rgba(var(--accent-rgb),.12); color: var(--accent); }

.count-line {
  font-size: .8rem; color: var(--text-muted);
  text-align: right; margin-bottom: 12px;
}

/* ============================================================
   SETTINGS TOGGLE
   ============================================================ */
.settings-box { border-top: 1px solid var(--border); padding-top: 12px; }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.toggle-row span { transition: color var(--dur); }
.toggle-row:hover span { color: var(--text); }

.toggle-wrap { position: relative; flex-shrink: 0; }
.toggle-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block; width: 36px; height: 20px;
  background: var(--border);
  border-radius: 99px;
  transition: background var(--dur);
  cursor: pointer;
}
.toggle-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform var(--dur);
}
.toggle-wrap input:checked + .toggle-track { background: var(--accent); }
.toggle-wrap input:checked + .toggle-track::after { transform: translateX(16px); }

/* ============================================================
   WHEEL AREA
   ============================================================ */
.wheel-area {
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
}

.wheel-wrap {
  position: relative;
  width: 100%; max-width: 520px;
  aspect-ratio: 1;
  filter: drop-shadow(0 10px 40px rgba(var(--accent-rgb),.2));
}

#wheelCanvas {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
}

.pointer-wrap {
  position: absolute; top: -8px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
.pointer-svg { display: block; }

/* Same [hidden] override needed — display:flex beats UA stylesheet */
.empty-overlay[hidden]    { display: none !important; }
.last-result-row[hidden]  { display: none !important; }

.empty-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border-radius: 50%;
  border: 3px dashed var(--border);
  transition: opacity .2s;
}
.empty-text {
  font-size: 1rem; color: var(--text-muted);
  font-weight: 500; text-align: center;
  padding: 20px;
}

/* ============================================================
   SPIN BUTTON
   ============================================================ */
.spin-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 0 48px;
  height: 58px;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: .08em;
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(var(--accent-rgb),.4);
  transition: background var(--dur), transform .1s, box-shadow var(--dur);
  overflow: hidden;
}
.spin-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.18), transparent);
}
.spin-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(var(--accent-rgb),.5);
}
.spin-btn:active:not(:disabled) { transform: translateY(0); }
.spin-btn:disabled {
  opacity: .45; cursor: not-allowed;
  box-shadow: none; transform: none;
}
.spin-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.spin-btn-sm {
  height: 46px; padding: 0 32px; font-size: .95rem;
}

/* ============================================================
   LAST RESULT + SHARE
   ============================================================ */
.last-result-row {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem;
  animation: fadeIn .3s ease;
}
.last-label { color: var(--text-muted); }
.last-value {
  font-weight: 700; color: var(--accent);
  max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.share-link-btn {
  display: flex; align-items: center; gap: 7px;
  font-size: .85rem; font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.share-link-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(var(--accent-rgb),.04); }

/* ============================================================
   HISTORY PANEL
   ============================================================ */
.history-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 400px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.history-empty {
  font-size: .875rem; color: var(--text-muted);
  text-align: center; padding: 24px 0;
}

.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  font-size: .85rem;
  animation: fadeInUp .15s ease;
}
.history-badge {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
}
.history-result {
  flex: 1; min-width: 0;
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-time { color: var(--text-muted); font-size: .78rem; flex-shrink: 0; }

/* ============================================================
   SEO BLOCK
   ============================================================ */
.seo-block {
  max-width: 1300px; margin: 40px auto 0;
  padding: 0 20px;
}
.seo-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.seo-inner h2 {
  font-size: 1.4rem; font-weight: 700;
  margin-bottom: 10px;
}
.seo-inner p {
  color: var(--text-muted); margin-bottom: 24px;
  max-width: 640px;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.feat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
}
.feat strong { font-size: .9rem; }
.feat span { font-size: .82rem; color: var(--text-muted); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  margin-top: 40px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 28px 20px;
}
.footer-inner {
  max-width: 1300px; margin: 0 auto;
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  text-align: center;
}
.footer-nav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 20px;
}
.footer-nav a {
  font-size: .875rem; color: var(--text-muted);
  transition: color var(--dur);
}
.footer-nav a:hover { color: var(--accent); text-decoration: none; }
.footer-copy {
  font-size: .8rem; color: var(--text-muted);
}

/* ============================================================
   MODALS / BACKDROP
   ============================================================ */
/* display:flex must be explicit — [hidden] from browser UA is overridden by class styles,
   so we re-enforce it here. Without this line closeModal() appears to do nothing. */
.backdrop[hidden] { display: none !important; }

.backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: backdropIn .15s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px;
  max-height: 90dvh; overflow-y: auto;
  animation: modalIn .22s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.9) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 0;
  margin-bottom: 16px;
}
.modal-head h2 { font-size: 1.15rem; font-weight: 700; }
.close-modal { color: var(--text-muted); }
.close-modal:hover { color: var(--text); }

/* Result modal */
.result-modal {
  text-align: center;
  padding: 40px 28px 32px;
  overflow: hidden;
}
.confetti-layer {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.confetti-piece {
  position: absolute; top: -10px;
  width: 10px; height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.result-icon {
  font-size: 3rem; margin-bottom: 10px;
  animation: iconBounce .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes iconBounce {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
.result-heading {
  font-size: 1rem; font-weight: 500;
  color: var(--text-muted); margin-bottom: 8px;
}
.result-name {
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 800; letter-spacing: -.02em;
  color: var(--accent);
  word-break: break-word;
  margin-bottom: 28px;
  animation: nameReveal .35s cubic-bezier(.34,1.56,.64,1) .1s both;
}
@keyframes nameReveal {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-actions {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

/* Templates modal */
.tpl-modal { max-width: 520px; }
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 0 22px 22px;
}
.tpl-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
  color: var(--text);
  text-align: center;
  transition: border-color var(--dur), background var(--dur), transform .1s;
}
.tpl-card:hover { border-color: var(--accent); background: rgba(var(--accent-rgb),.05); transform: translateY(-2px); }
.tpl-card:active { transform: translateY(0); }
.tpl-icon { font-size: 1.5rem; }
.tpl-count { font-size: .75rem; color: var(--text-muted); font-weight: 400; }

/* Share modal */
.share-modal { padding: 0 0 22px; }
.share-modal p { padding: 0 22px; font-size: .9rem; color: var(--text-muted); margin-bottom: 12px; }
.share-url-row {
  display: flex; gap: 8px;
  padding: 0 22px; margin-bottom: 14px;
}
.share-url-input {
  flex: 1; min-width: 0;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: .82rem;
  outline: none;
}
.native-share-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0 22px;
  padding: 10px 18px;
  width: calc(100% - 44px);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: .9rem; font-weight: 600;
  transition: border-color var(--dur), background var(--dur);
}
.native-share-btn:hover { border-color: var(--accent); background: rgba(var(--accent-rgb),.05); }

/* Themes modal */
.themes-modal { max-width: 380px; }
.themes-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 0 22px 22px;
}
.theme-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2.5px solid transparent;
  transition: border-color var(--dur), transform .1s;
}
.theme-card:hover { transform: scale(1.05); }
.theme-card.active { border-color: var(--accent); }
.theme-swatch {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toastContainer {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .875rem; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: auto;
}
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px) scale(.9); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toastOut { from { opacity:1; transform:translateY(0) scale(1); } to { opacity:0; transform:translateY(8px) scale(.95); } }

/* ============================================================
   SPINNING STATE
   ============================================================ */
body.is-spinning .spin-btn { pointer-events: none; }
body.is-spinning .add-btn,
body.is-spinning .option-delete,
body.is-spinning #clearAllBtn { opacity: .4; pointer-events: none; }

/* ============================================================
   WHEEL GLOW ANIMATION (applied via JS during spin)
   ============================================================ */
.wheel-wrap.spinning {
  filter: drop-shadow(0 10px 40px rgba(var(--accent-rgb),.4))
          drop-shadow(0 0 80px rgba(var(--accent-rgb),.15));
}

/* ============================================================
   MOBILE TOUCH IMPROVEMENTS
   ============================================================ */
@media (hover: none) {
  .option-delete { opacity: 1; }
}

@media (max-width: 600px) {
  .wheel-wrap { max-width: 320px; }
  .spin-btn { height: 52px; padding: 0 36px; font-size: 1rem; }
  .panel { padding: 14px; }
  .seo-inner { padding: 20px; }
  .themes-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .ad-mid { display: none; }
}
