/* Katachi-go game — retro-futuristic synthwave theme (neon sunset, grid horizon) */
:root {
  --navy: #1c0a30;      /* deep purple panel bg */
  --offwhite: #150821;  /* page background base (body uses a gradient over this) */
  --white: #f5edff;     /* light lavender-white text */
  --blue: #38d0ff;      /* neon cyan-blue */
  --orange: #ff9d4d;    /* neon orange (also the ball "gold rim" color in render.js) */
  --yellow: #ffd76a;    /* sun-top gold */
  --mauve: #ff4fa0;     /* neon pink */
  --board: #170821;     /* board frame background */
  --dimple: #2a1240;    /* empty-cell accent */
  --font-script: 'Orbitron', sans-serif;
  --font-body: 'Raleway', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--offwhite) radial-gradient(ellipse at 50% 15%, #4a1a66 0%, #23103a 45%, #150821 80%);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav (matches site, dark synthwave variant) ── */
nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 2rem; background: rgba(21,8,33,0.9); backdrop-filter: blur(6px);
  box-shadow: 0 2px 16px rgba(255,79,160,0.15), 0 1px 0 rgba(255,255,255,0.06);
  position: sticky; top: 0; z-index: 50;
}
.nav-logo { text-decoration: none; }
.nav-logo-main { font-family: var(--font-script); font-size: 1.5rem; font-weight: 700; color: var(--white); letter-spacing: 0.03em; }
.nav-links { display: flex; gap: 1.4rem; list-style: none; align-items: center; }
.nav-links a { color: var(--white); text-decoration: none; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.nav-links a:hover { color: var(--blue); }
.nav-cta {
  background: linear-gradient(90deg, var(--orange), var(--mauve)); color: var(--white); border: none; border-radius: 99px;
  padding: 0.55rem 1.2rem; font-family: var(--font-body); font-weight: 800; font-size: 0.8rem;
  letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer; text-decoration: none;
  display: inline-block; transition: transform 0.15s, box-shadow 0.15s;
}
.nav-cta:hover { box-shadow: 0 0 18px rgba(255,79,160,0.55); transform: translateY(-1px); }
.nav-search { position: relative; }
.nav-search input[type="search"] { width: 130px; padding: 0.45rem 0.9rem; border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; font-family: var(--font-body); font-size: 0.8rem; background: rgba(255,255,255,0.06); color: var(--white); transition: width 0.2s ease, background 0.2s ease; }
.nav-search input[type="search"]::placeholder { color: rgba(245,237,255,0.45); }
.nav-search input[type="search"]:focus { outline: none; width: 190px; background: rgba(255,255,255,0.1); border-color: var(--blue); }
.nav-search-results { position: absolute; top: calc(100% + 0.6rem); right: 0; width: 280px; background: var(--navy); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-height: 20rem; overflow-y: auto; display: none; z-index: 300; }
.nav-search-results.open { display: block; }
.nsr-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; text-decoration: none; color: inherit; border-bottom: 1px solid rgba(255,255,255,0.08); }
.nsr-item:last-child { border-bottom: none; }
.nsr-item:hover { background: rgba(255,255,255,0.06); }
.nsr-item img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.nsr-item-name { font-size: 0.85rem; font-weight: 700; color: var(--white); }
.nsr-empty { padding: 0.8rem; font-size: 0.82rem; color: #9d8cc2; text-align: center; }
.nav-account-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(56,208,255,0.12); color: var(--blue); border: 2px solid rgba(56,208,255,0.35); border-radius: 99px;
  padding: 0.4rem 0.85rem; font-family: var(--font-body); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.03em; cursor: pointer;
}
.nav-account-badge::before { content: ''; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--blue); }
.nav-account-badge:hover { border-color: var(--blue); }
.nav-account-badge[hidden] { display: none; }

main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ── Level select ── */
.hero-title { font-family: var(--font-script); font-weight: 700; font-size: 2.4rem; text-align: center; margin-top: 0.5rem; color: var(--white); text-shadow: 0 0 22px rgba(255,79,160,0.55), 0 0 46px rgba(56,208,255,0.25); letter-spacing: 0.02em; }
.hero-sub { text-align: center; color: #cbb8ec; font-size: 0.95rem; max-width: 34rem; margin: 0.4rem auto 1.6rem; line-height: 1.5; }
.top-row { display: flex; align-items: stretch; gap: 1rem; margin-bottom: 1.6rem; }
.daily-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: linear-gradient(135deg, #3a1256, #1c0a30); color: var(--white); border-radius: 16px;
  border: 1px solid rgba(255,157,77,0.35);
  padding: 1rem 1.3rem; flex: 0 0 auto; max-width: 20rem; flex-wrap: wrap;
}
.daily-card h2 { font-family: var(--font-script); font-size: 1.15rem; font-weight: 700; color: var(--orange); }
.daily-card p { font-size: 0.85rem; color: #c9c9e0; margin-top: 0.15rem; }
.btn {
  background: linear-gradient(90deg, var(--orange), var(--mauve)); color: var(--white); border: none; border-radius: 99px;
  padding: 0.6rem 1.4rem; font-family: var(--font-body); font-weight: 800; font-size: 0.85rem;
  letter-spacing: 0.04em; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { box-shadow: 0 0 18px rgba(255,79,160,0.5); transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--white); border: 2px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(56,208,255,0.1); border-color: var(--blue); }

.tier-tabs { display: flex; flex-direction: column-reverse; flex-wrap: nowrap; gap: 0.4rem; align-items: center; justify-content: flex-start; flex: 1; }
.tier-btn {
  background: rgba(255,255,255,0.04); border: 2px solid rgba(255,255,255,0.14); border-radius: 99px; padding: 0.45rem 1.1rem;
  font-family: var(--font-body); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.07em;
  text-transform: uppercase; cursor: pointer; color: var(--white); transition: all 0.2s;
  white-space: nowrap; max-width: 92vw;
}
.tier-btn:hover { border-color: var(--blue); color: var(--blue); }
.tier-btn.active { background: linear-gradient(90deg, var(--blue), var(--mauve)); border-color: transparent; color: var(--white); box-shadow: 0 0 16px rgba(56,208,255,0.4); }
.tier-tabs .tier-btn:nth-child(1) { width: 22rem; }
.tier-tabs .tier-btn:nth-child(2) { width: 20.4rem; }
.tier-tabs .tier-btn:nth-child(3) { width: 18.8rem; }
.tier-tabs .tier-btn:nth-child(4) { width: 17.2rem; }
.tier-tabs .tier-btn:nth-child(5) { width: 15.6rem; }
.tier-tabs .tier-btn:nth-child(6) { width: 14rem; }
.tier-tabs .tier-btn:nth-child(7) { width: 12.5rem; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 0.6rem; }
.level-btn {
  aspect-ratio: 1; border-radius: 14px; border: 2px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.04);
  font-family: var(--font-body); font-weight: 800; font-size: 1rem; color: var(--white);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.15rem; transition: all 0.15s;
}
.level-btn:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 0 14px rgba(56,208,255,0.3); }
.level-btn.done { background: rgba(255,157,77,0.14); border-color: var(--orange); }
.level-btn .check { font-size: 0.8rem; color: var(--orange); }

/* ── SEO blurb / FAQ (level-select page only) ── */
.seo-blurb { margin-top: 2.2rem; padding-top: 1.4rem; border-top: 1px solid rgba(255,255,255,0.12); }
.seo-blurb > p { color: #cbb8ec; font-size: 0.9rem; line-height: 1.6; max-width: 40rem; margin: 0.6rem auto 1.2rem; text-align: center; }
.faq-item {
  max-width: 40rem; margin: 0 auto 0.6rem; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  padding: 0.7rem 1rem;
}
.faq-item summary { font-weight: 700; font-size: 0.88rem; color: var(--white); cursor: pointer; }
.faq-item p { font-size: 0.85rem; color: #cbb8ec; line-height: 1.55; margin-top: 0.5rem; }

/* ── Game view ── */
.game-topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.game-title { font-weight: 800; font-size: 1rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--white); }
.game-title .tier { color: var(--orange); }
.board-wrap { background: var(--board); border: 1px solid rgba(56,208,255,0.25); border-radius: 18px; padding: 10px; box-shadow: 0 0 30px rgba(255,79,160,0.15), 0 6px 24px rgba(0,0,0,0.45); }
#boardWrap { max-width: 90%; margin: 0 auto; }
#boardSvg { display: block; width: 100%; height: auto; touch-action: manipulation; }
#boardSvg .cell-hit { cursor: pointer; }

.controls-hint { text-align: center; font-size: 1rem; color: #cbb8ec; margin: 0.7rem 0 0.3rem; }
.tray {
  display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: center;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 0.8rem; margin-top: 0.8rem;
  min-height: 72px;
}
.tray-piece {
  background: rgba(255,255,255,0.05); border: 2px solid transparent; border-radius: 12px; padding: 6px;
  cursor: pointer; transition: border-color 0.12s, background 0.12s, opacity 0.12s; line-height: 0;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.tray-piece:hover { border-color: var(--blue); }
.tray-piece.selected { border-color: var(--orange); background: rgba(255,157,77,0.14); }
.tray-piece.dragging-source { opacity: 0.35; }
.tray-empty { color: #9d8cc2; font-size: 1.6rem; align-self: center; }

/* ── Drag ghost (follows pointer while dragging a piece from the tray) ── */
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 150; pointer-events: none;
  opacity: 0.88; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
}

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.board-wrap.shake { animation: shake 0.25s; }

/* ── Win modal ── */
.overlay {
  position: fixed; inset: 0; background: rgba(10,4,18,0.75); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.overlay.open { display: flex; }
.win-modal {
  background: linear-gradient(160deg, #2b1140, #170821); border: 1px solid rgba(255,79,160,0.35); border-radius: 20px; padding: 2rem 1.8rem; max-width: 24rem;
  text-align: center; box-shadow: 0 0 60px rgba(255,79,160,0.25), 0 20px 60px rgba(0,0,0,0.5);
}
.win-modal h2 { font-family: var(--font-script); font-size: 2rem; color: var(--orange); text-shadow: 0 0 18px rgba(255,157,77,0.6); }
.win-modal p { color: #cbb8ec; font-size: 0.92rem; line-height: 1.55; margin: 0.7rem 0 1.2rem; }
.win-actions { display: flex; flex-direction: column; gap: 0.55rem; }

.win-stars { font-size: 2.2rem; color: var(--yellow); line-height: 1; margin-top: 0.3rem; letter-spacing: 0.1em; }
.win-thrust { font-weight: 800; font-size: 1.3rem; color: var(--white); margin-top: 0.2rem; }
.win-best { color: var(--orange); font-weight: 700; font-size: 0.85rem; margin-top: 0.3rem; }
.win-streak { color: var(--mauve); font-weight: 700; font-size: 0.85rem; margin-top: 0.2rem; }
.win-badges { margin-top: 0.4rem; }

/* ── Win celebration: neon flash + particle burst ── */
.celebrate-flash {
  position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center;
}
.celebrate-flash::after {
  content: ''; width: 60vmax; height: 60vmax; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,79,160,0.85) 0%, rgba(56,208,255,0.4) 35%, rgba(56,208,255,0) 70%);
  opacity: 0; transform: scale(0.3);
}
.celebrate-flash.play::after { animation: sunFlash 0.9s ease-out; }
@keyframes sunFlash {
  0% { opacity: 0; transform: scale(0.3) rotate(0deg); }
  30% { opacity: 1; transform: scale(1) rotate(20deg); }
  100% { opacity: 0; transform: scale(1.5) rotate(35deg); }
}

.celebrate-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.particle {
  position: absolute; left: 50%; top: 42%; width: 1.5rem; height: 1.5rem; margin: -0.75rem;
  opacity: 0; animation: burstFall 1.5s ease-out forwards; animation-delay: var(--delay, 0s);
}
.particle.coin {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff2c9, var(--mauve) 60%, #7a1e5c 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4), 0 0 10px rgba(255,79,160,0.6);
}
.particle.scarab svg { width: 100%; height: 100%; display: block; }
@keyframes burstFall {
  0% { transform: translate(0, 0) rotate(0deg) scale(0.4); opacity: 0; }
  14% { opacity: 1; transform: translate(calc(var(--dx) * 0.3), calc(var(--dy) * 0.3)) rotate(90deg) scale(1); }
  100% { transform: translate(var(--dx), calc(var(--dy) + 230px)) rotate(var(--rot)) scale(0.85); opacity: 0; }
}
.badge-unlock, .badge-earned {
  background: rgba(255,157,77,0.12); border: 1px solid rgba(255,157,77,0.4); border-radius: 10px; padding: 0.4rem 0.7rem;
  font-size: 0.82rem; font-weight: 600; color: var(--orange); margin-top: 0.4rem;
}

/* ── Stars on level buttons ── */
.check.stars { font-size: 0.7rem; color: var(--yellow); letter-spacing: 0.05em; display: block; margin-top: 0.1rem; }

/* ── Stats view ── */
.stats-link-row { text-align: center; margin: -0.4rem 0 1.2rem; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin: 1rem 0 1.4rem; }
.stat-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 1rem 0.6rem; text-align: center; }
.stat-num { font-weight: 800; font-size: 1.6rem; color: var(--white); }
.stat-label { font-size: 0.72rem; color: #9d8cc2; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.2rem; }
.stats-subhead { font-size: 0.95rem; font-weight: 800; color: var(--white); margin: 1.2rem 0 0.5rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-row {
  display: flex; justify-content: space-between; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
  padding: 0.55rem 0.9rem; margin-bottom: 0.4rem; font-size: 0.88rem; color: var(--white);
}
.stats-empty { color: #9d8cc2; font-size: 0.85rem; }

/* ── Account / sync block ── */
.account-block {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 1rem 1.1rem; margin: 1rem 0 1.4rem;
  text-align: center;
}
.account-label { font-size: 0.85rem; font-weight: 700; color: var(--white); margin-bottom: 0.6rem; }
.account-form { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.account-form input {
  flex: 1 1 12rem; border: 2px solid rgba(255,255,255,0.16); border-radius: 99px; padding: 0.5rem 1rem;
  font-family: var(--font-body); font-size: 0.85rem; color: var(--white); background: rgba(255,255,255,0.05);
}
.account-form input:focus { outline: none; border-color: var(--blue); }
.account-msg { font-size: 0.78rem; color: #9d8cc2; margin-top: 0.5rem; min-height: 1.1em; }

/* ── Install prompt ── */
#installBtn { display: none; color: var(--white); }

/* ── Footer (matches site) ── */
footer { background: var(--navy); color: var(--white); text-align: center; padding: 1.6rem 1rem; margin-top: 2rem; border-top: 1px solid rgba(255,79,160,0.2); }
.footer-logo { font-family: var(--font-script); font-size: 1.3rem; font-weight: 700; display: block; margin-bottom: 0.3rem; }
footer p { font-size: 0.8rem; color: #c9c9e0; }
footer a { color: var(--blue); }

.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: linear-gradient(90deg, var(--mauve), var(--blue)); color: var(--white); border-radius: 99px; padding: 0.6rem 1.3rem;
  font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; z-index: 200; box-shadow: 0 4px 20px rgba(255,79,160,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Physical puzzle (coming soon) page ── */
.physical-badge-row { text-align: center; margin: -0.6rem 0 1.2rem; }
.coming-soon-badge {
  display: inline-block; background: var(--yellow); color: var(--navy);
  font-weight: 800; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.35rem 0.9rem; border-radius: 99px;
}

/* ── Puzzle Solutions page (unused by Katachi-go currently, kept for parity) ── */
.level-btn.viewing { border-color: var(--orange); background: rgba(255,157,77,0.14); }
.solutions-detail { margin-top: 0.5rem; }
.solution-boards { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }
.solution-board-col { flex: 1 1 260px; max-width: 360px; }
.solution-board-label {
  text-align: center; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--white); margin-bottom: 0.4rem;
}
.solution-hidden-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.9rem; min-height: 180px; padding: 1.6rem 1.2rem;
}
.solution-hidden-panel[hidden] { display: none; }
.solution-warning { color: #e8d5b5; font-size: 0.82rem; line-height: 1.5; margin: 0; }
.legend-section { margin-top: 2rem; }
.legend-grid { display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: center; }
.legend-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 0.6rem 0.8rem;
  font-size: 0.72rem; font-weight: 700; color: #cbb8ec;
  min-width: 4.5rem;
}
.legend-letter {
  display: flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: #0D0D2B; color: #fff; font-size: 0.78rem; font-weight: 800;
}

@media (max-width: 560px) {
  nav { padding: 0.7rem 1rem; }
  .nav-links { display: none; }
  .nav-search { display: none; }
  .hero-title { font-size: 2.1rem; }
  main { padding: 1rem 0.7rem 2.5rem; }
  .top-row { flex-direction: column; }
  .daily-card { max-width: none; }
}
