/* =============================================
   SEPTLE PREMIUM — REDESIGNED CSS
   Replace this file at /ctx-assets/game.css
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --green:   #22c55e;
  --green-d: #16a34a;
  --yellow:  #eab308;
  --yellow-d:#ca8a04;
  --gray:    #6b7280;
  --gray-d:  #4b5563;
  --red:     #ef4444;

  --bg:      #0d0f1a;
  --card:    #13162a;
  --card2:   #1a1e35;
  --surface: #20264a;
  --border:  rgba(139,120,255,0.18);
  --border2: rgba(139,120,255,0.08);

  --txt:     #f0f0ff;
  --txt2:    #8b8baa;
  --txt3:    #5a5a7a;

  --purple:  #7c3aed;
  --purple-l:#a855f7;
  --purple-xl:#c084fc;
  --accent:  #7c3aed;

  --hdr-h:   56px;
  --radius:  14px;
  --radius-sm: 8px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

body.theme-light {
  --bg:      #f4f4f8;
  --card:    #ffffff;
  --card2:   #f8f8fc;
  --surface: #ededf5;
  --border:  rgba(100,80,200,0.15);
  --border2: rgba(100,80,200,0.06);
  --txt:     #111130;
  --txt2:    #5a5a7a;
  --txt3:    #9090b0;
  --purple:  #6d28d9;
  --purple-l:#7c3aed;
  --purple-xl:#a855f7;
  --accent:  #6d28d9;
}

body.theme-spring {
  --bg:      #1a0d1a;
  --card:    #220d22;
  --card2:   #2a142a;
  --surface: #331433;
  --border:  rgba(236,72,153,0.2);
  --border2: rgba(236,72,153,0.08);
  --purple:  #db2777;
  --purple-l:#ec4899;
  --purple-xl:#f472b6;
  --accent:  #db2777;
  --green:   #ec4899;
  --green-d: #db2777;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
  transition: background var(--transition), color var(--transition);
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: .6;
}

body::after {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(124,58,237,.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  box-shadow: 0 0 60px rgba(0,0,0,0.4), 0 0 0 1px var(--border2);
  overflow: hidden;
  position: relative;
}

/* =============================================
   HEADER
   ============================================= */
.hdr {
  height: var(--hdr-h);
  background: linear-gradient(135deg, rgba(124,58,237,.15) 0%, rgba(168,85,247,.08) 100%);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
  position: relative;
}

.hdr::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--purple-l), transparent);
  opacity: .4;
}

.hdr-side {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 76px;
}
.hdr-side.right { justify-content: flex-end; }

.hdr-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hdr-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--txt);
  letter-spacing: 5px;
  font-family: 'DM Mono', 'Courier New', monospace;
}

.hdr-sub {
  font-size: 10px;
  color: var(--purple-xl);
  font-weight: 700;
  letter-spacing: 1px;
}

.hbtn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--txt2);
  flex-shrink: 0;
}

.hbtn:hover {
  background: rgba(124,58,237,.2);
  border-color: var(--purple);
  color: var(--txt);
  transform: translateY(-1px);
}

.hbtn svg {
  width: 17px; height: 17px;
  stroke: currentColor; fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =============================================
   SCREENS
   ============================================= */
.scr {
  flex: 1;
  padding: 16px 14px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  animation: scrIn .22s cubic-bezier(.4,0,.2,1);
}

.scr::-webkit-scrollbar { width: 3px; }
.scr::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.hidden { display: none !important; }

@keyframes scrIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* =============================================
   HOME SCREEN
   ============================================= */
.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.home-intro {
  font-size: 13px;
  color: var(--txt2);
  font-weight: 500;
  line-height: 1.5;
}

.home-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-xl);
  background: rgba(124,58,237,.1);
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  font-family: 'DM Mono', 'Courier New', monospace;
}

.timer-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.7); }
}

.mode-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--card2);
  overflow: hidden;
  transition: all var(--transition);
  position: relative;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--mode-color, var(--purple));
  border-radius: 3px 0 0 3px;
}

.mode-card:hover {
  border-color: rgba(124,58,237,.35);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.mode-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px 13px 17px;
}

.mode-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  font-family: 'DM Mono', 'Courier New', monospace;
  flex-shrink: 0;
  color: #fff;
}

.mode-info { flex: 1; min-width: 0; }

.mode-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 2px;
}

.mode-desc {
  font-size: 11px;
  color: var(--txt3);
  font-weight: 500;
  margin-bottom: 4px;
}

.mode-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}
.mode-status.orange { color: #f59e0b; }
.mode-status.green  { color: var(--green); }
.mode-status.red    { color: var(--red); }

.mode-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.play-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  color: #fff;
  white-space: nowrap;
  letter-spacing: .3px;
}

.play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

.play-btn:active { transform: scale(.95); }

.home-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--txt3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.home-divider::before,
.home-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ha-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  color: var(--txt);
  line-height: 1.2;
  text-align: center;
}

.ha-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.15); }

.ha-btn.ha-green  { color: var(--green); border-color: rgba(34,197,94,.2);   background: rgba(34,197,94,.05); }
.ha-btn.ha-yellow { color: var(--yellow); border-color: rgba(234,179,8,.2);  background: rgba(234,179,8,.05); }
.ha-btn.ha-orange { color: #f97316; border-color: rgba(249,115,22,.2);       background: rgba(249,115,22,.05); }
.ha-btn.ha-purple { color: var(--purple-xl); border-color: var(--border); }

.ha-btn:hover.ha-green  { background: rgba(34,197,94,.1);  border-color: rgba(34,197,94,.3); }
.ha-btn:hover.ha-yellow { background: rgba(234,179,8,.1);  border-color: rgba(234,179,8,.3); }
.ha-btn:hover.ha-orange { background: rgba(249,115,22,.1); border-color: rgba(249,115,22,.3); }
.ha-btn:hover.ha-purple { background: rgba(124,58,237,.1); border-color: var(--purple); }

.home-footer {
  font-size: 11px;
  color: var(--txt3);
  text-align: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border2);
}

.home-footer a { color: var(--purple-xl); text-decoration: none; }

/* =============================================
   SCREEN HEADER (shared)
   ============================================= */
.scr-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 10px;
  font-family: inherit;
  transition: all var(--transition);
}

.back-btn:hover {
  color: var(--txt);
  border-color: var(--purple);
  background: rgba(124,58,237,.1);
}

.scr-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--txt);
  letter-spacing: .5px;
}

.scr-placeholder { width: 60px; }

/* =============================================
   GAME SCREEN
   ============================================= */
.lives-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  height: 20px;
  align-items: center;
}

.life {
  font-size: 14px;
  transition: all .3s;
  filter: drop-shadow(0 0 4px rgba(239,68,68,.5));
}

.life.lost {
  filter: grayscale(1);
  opacity: .3;
}

/* Toast */
.toast {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  min-height: 32px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  letter-spacing: .2px;
}

.t0 { background: transparent; border: 1px solid transparent; color: transparent; }
.tw { background: rgba(34,197,94,.1); color: var(--green); border: 1px solid rgba(34,197,94,.2); }
.te { background: rgba(239,68,68,.1); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.ti { background: rgba(124,58,237,.1); color: var(--purple-xl); border: 1px solid var(--border); }

/* Grid */
.grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  margin: 0 0 10px;
}

.row { display: flex; gap: 5px; }

.tile {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--txt);
  background: var(--card2);
  transition: border-color .1s, background .1s;
  user-select: none;
  font-family: 'DM Mono', 'Courier New', monospace;
  position: relative;
}

.tile.cur  {
  border-color: var(--purple-l);
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(124,58,237,.15);
}

.tile.fill { border-color: var(--txt3); }

.tile.c  { background: var(--green);  border-color: var(--green-d); color: #fff; box-shadow: 0 4px 12px rgba(34,197,94,.25); }
.tile.p  { background: var(--yellow); border-color: var(--yellow-d); color: #fff; box-shadow: 0 4px 12px rgba(234,179,8,.25); }
.tile.a  { background: var(--gray);   border-color: var(--gray-d); color: #fff; }

@keyframes pop    { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
@keyframes shake  { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-5px)} 40%,80%{transform:translateX(5px)} }
@keyframes bounce { 0%,100%{transform:translateY(0)} 40%{transform:translateY(-10px)} }
@keyframes flipIn { 0%{transform:scaleY(1)} 50%{transform:scaleY(0)} 100%{transform:scaleY(1)} }

.pop    { animation: pop    .14s ease; }
.shake  { animation: shake  .4s ease; }
.bounce { animation: bounce .5s ease; }
.flip   { animation: flipIn .36s ease; }

/* Keyboard */
.kb { padding: 0 2px; }

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 5px;
}

.key {
  height: 52px;
  min-width: 26px;
  max-width: 36px;
  flex: 1;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--txt);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all .1s;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-family: 'DM Mono', 'Courier New', monospace;
}

.key:hover { background: rgba(124,58,237,.2); border-color: var(--purple); }
.key:active { transform: scale(.9); }
.key.wide  { max-width: 56px; font-size: 10px; font-family: inherit; }
.key.c { background: var(--green);  border-color: var(--green-d); color: #fff; }
.key.p { background: var(--yellow); border-color: var(--yellow-d); color: #000; }
.key.a { background: var(--gray);   border-color: var(--gray-d); color: #fff; }

/* =============================================
   STATS SCREEN
   ============================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}

.stat-n {
  font-size: 28px;
  font-weight: 900;
  color: var(--txt);
  font-family: 'DM Mono', 'Courier New', monospace;
  line-height: 1;
}

.stat-icon { font-size: 18px; display: block; margin-bottom: 4px; }
.stat-l { font-size: 10px; color: var(--txt3); margin-top: 5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }

.stats-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.stats-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--txt3);
  margin-bottom: 12px;
}

.bars { display: flex; flex-direction: column; gap: 4px; }
.brow { display: flex; align-items: center; gap: 8px; }

.blbl {
  width: 14px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: var(--txt3);
  font-family: 'DM Mono', 'Courier New', monospace;
}

.btrk {
  flex: 1;
  background: var(--surface);
  border-radius: 5px;
  height: 22px;
  overflow: hidden;
}

.bfill {
  height: 100%;
  background: var(--gray);
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  min-width: 28px;
  transition: width .7s cubic-bezier(.4,0,.2,1);
}

.bfill.best { background: linear-gradient(90deg, var(--purple), var(--purple-l)); }

.score-grid { display: flex; gap: 8px; margin-bottom: 14px; }

.score-box {
  flex: 1;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  border: 1px solid var(--border2);
}

.score-val { font-size: 20px; font-weight: 900; color: var(--txt); font-family: 'DM Mono', 'Courier New', monospace; }
.score-lbl { font-size: 10px; color: var(--txt3); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }

.share-row { display: flex; gap: 8px; }

.share-btn, .copy-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  letter-spacing: .2px;
}

.share-btn { background: linear-gradient(135deg, var(--purple), var(--purple-l)); color: #fff; }
.copy-btn  { background: var(--surface); color: var(--txt); border: 1px solid var(--border); }
.share-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,58,237,.3); }
.copy-btn:hover  { transform: translateY(-1px); border-color: var(--purple); }

/* =============================================
   SETTINGS SCREEN
   ============================================= */
.set-section {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}

.set-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--txt3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border2);
  background: var(--surface);
}

.theme-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; padding: 12px 14px; }

.theme-opt {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  transition: all var(--transition);
}

.theme-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,.2); }

.theme-prev {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tp { width: 10px; height: 10px; border-radius: 50%; }

.theme-opt span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--txt2);
  padding: 5px 2px;
  background: var(--card2);
  letter-spacing: .3px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border2);
}

.set-row:last-child { border-bottom: none; }

.set-row-info { flex: 1; }
.set-lbl { font-size: 14px; font-weight: 600; color: var(--txt); }
.set-desc { font-size: 11px; color: var(--txt3); margin-top: 2px; }

/* Toggle */
.tog { position: relative; width: 44px; height: 25px; display: inline-block; flex-shrink: 0; }
.tog input { opacity: 0; width: 0; height: 0; }

.ts {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: 25px;
  cursor: pointer;
  transition: .2s;
  border: 1px solid var(--border);
}

.ts::before {
  content: '';
  position: absolute;
  width: 19px; height: 19px;
  left: 2px; top: 2px;
  background: var(--txt3);
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

input:checked + .ts { background: var(--accent); border-color: var(--purple); }
input:checked + .ts::before { transform: translateX(19px); background: #fff; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 480px) {
  .tile { width: 40px; height: 40px; font-size: 16px; }
  .key  { height: 46px; }
  .key.wide { max-width: 50px; }
  .theme-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-height: 700px) {
  .tile { width: 38px; height: 38px; font-size: 15px; }
  .grid { gap: 4px; margin-bottom: 8px; }
  .kb-row { margin-bottom: 4px; }
  .key { height: 44px; }
}
