:root{
  --bg:#fbf8f2;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e5edf5;
  --accent:#20c3b6;
  --accent-2:#7c3aed;
  --accent-3:#f59e0b;
  --shadow: 0 18px 40px rgba(15,23,42,.10);
  --shadow-soft: 0 10px 20px rgba(15,23,42,.08);
  --radius: 22px;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: #ffffff;
  color: var(--text);
}

.screen{
  display:none;
  padding: 28px 16px;
  min-height:100vh;
  align-items:center;
  justify-content:center;
}
.screen.active{display:flex}

.hero{
  max-width: 760px;
  width:100%;
  text-align:center;
}

.version-tools{
  position: fixed;
  left: 12px;
  bottom: 12px;
  display:flex;
  align-items:center;
  gap:8px;
}

.version-stamp{
  font-size: 11px;
  color: var(--muted);
  opacity: 0.6;
  letter-spacing: 0.2px;
  user-select: none;
}

.wake-server-btn{
  border:1px solid #d8e4ef;
  background:#ffffff;
  color:#64748b;
  font-size:10px;
  padding:2px 7px;
  border-radius:999px;
  opacity:.75;
  cursor:pointer;
}
.wake-server-btn:hover{ opacity:1; }
.wake-server-btn:disabled{
  cursor:wait;
  opacity:.55;
}
.wake-server-btn[data-state="up"]{
  border-color:#bbf7d0;
  color:#15803d;
}
.wake-server-btn[data-state="down"]{
  border-color:#fecaca;
  color:#b91c1c;
}
.wake-server-btn[data-state="checking"]{
  border-color:#bfdbfe;
  color:#1d4ed8;
}

.logo{
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 12px;
  user-select:none;
}
.logo span{display:inline-block}
.c1{color:#f97316}.c2{color:#3b82f6}.c3{color:#22c55e}.c4{color:#eab308}
.c5{color:#ef4444}.c6{color:#8b5cf6}.c7{color:#06b6d4}.c8{color:#ec4899}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid #efe2ff;
  padding: 8px 16px;
  border-radius: 999px;
  color: #7c3aed;
  background: #f5ecff;
  font-weight:700;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.spark{opacity:.8}

.hero-title{
  font-size: 32px;
  margin: 0 0 6px 0;
}
.hero-subtitle{
  margin: 0 0 18px 0;
  color: var(--muted);
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 760px;
  width: 100%;
}

.hero-card{
  padding: 22px;
  border: 2px solid rgba(32,195,182,.35);
  background: linear-gradient(180deg, #ffffff 0%, #f7fffe 100%);
}

.mode-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  margin-bottom: 14px;
}

.mode-card{
  border:1px solid #d8e4ef;
  border-radius: 18px;
  padding: 16px;
  background: #ffffff;
  cursor:pointer;
  text-align:left;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.mode-card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  background:#f4f8ff;
}
.mode-card.selected{
  border-color: #60a5fa;
  box-shadow: 0 12px 30px rgba(59,130,246,.28);
  background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);
  color:#ffffff;
}
.mode-title{font-size:16px;margin-bottom:6px}
.mode-desc{color:var(--muted);font-size:13px}
.mode-card.selected .mode-desc{color:#e0f2fe}

.defis-card{
  width:100%;
  border:1px solid #d8e4ef;
  border-radius: 18px;
  padding: 16px;
  background: #ffffff;
  cursor:pointer;
  text-align:left;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  margin-bottom: 14px;
}
.defis-card.selected{
  border-color: #60a5fa;
  box-shadow: 0 12px 30px rgba(59,130,246,.28);
  background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);
  color:#ffffff;
}
.defis-card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  background:#f4f8ff;
}
.defis-card.selected:hover{background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);}
.defis-left{display:flex;gap:12px;align-items:flex-start}
.defis-icon{
  width:40px;height:40px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  background:#e0f2fe;
  border:1px solid #bae6fd;
  font-size:20px;
}
.defis-title{font-size:16px}
.defis-sub{color:var(--muted);font-size:13px;margin-top:2px}
.defis-card.selected .defis-sub{color:#e0f2fe}
.defis-tags{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.tag{
  font-size:12px;
  border:1px solid #d8e4ef;
  border-radius:999px;
  padding:4px 8px;
  color: var(--muted);
  background:#ffffff;
}
.defis-card.selected .tag{
  border:1px solid rgba(255,255,255,.55);
  color: #ffffff;
  background:rgba(255,255,255,.2);
}

.main-btn{
  width:100%;
  border:none;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor:pointer;
  background: linear-gradient(90deg, #20c3b6 0%, #3b82f6 100%);
  color:#fff;
  box-shadow: 0 12px 26px rgba(59,130,246,.25);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.main-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(59,130,246,.3);
  filter: brightness(1.08);
}
.secondary-btn{
  width:100%;
  margin-top: 10px;
  border:1px solid #d8e4ef;
  border-radius: 16px;
  padding: 12px 14px;
  background:#ffffff;
  cursor:pointer;
  color: var(--text);
  font-weight: 600;
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.secondary-btn:hover{
  background:#f4f8ff;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}
.link-btn{
  border:none;
  background:transparent;
  color:#334155;
  cursor:pointer;
  font-weight:700;
}

.topline h2{margin:0}
.subtitle{margin:6px 0 0 0;color:var(--muted)}
.center{ text-align:center }
.center-title{ text-align:center; margin:0 }

.alphabet{
  margin-top: 14px;
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.letter-btn{
  border:1px solid #d8e4ef;
  background:#ffffff;
  border-radius: 16px;
  padding: 10px;
  cursor:pointer;
  text-align:center;
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.letter-btn:hover{
  background:#f4f8ff;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}
.letter-top{font-weight:900;font-size:18px}
.letter-sub{color:var(--muted);font-size:12px;margin-top:2px}

.progress-card{
  border:1px solid #e8eff6;
  border-radius: 18px;
  padding: 12px;
  margin: 12px 0;
  background: #fbfdff;
}
.progress-top{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
}
.progress-big{font-size:22px;font-weight:900}
.bar{
  height:10px;
  background:#eef2f7;
  border-radius: 999px;
  overflow:hidden;
  margin-top:10px;
}
.bar-fill{
  height:100%;
  background: linear-gradient(90deg, #20c3b6 0%, #3b82f6 100%);
  width:0%;
}

.word-row{
  display:flex;
  gap:10px;
  align-items:center;
}
.letter-chip{
  width:46px;height:46px;
  border-radius: 16px;
  display:flex;align-items:center;justify-content:center;
  background:#f2fffd;
  border:1px solid #d6f5f0;
  font-size:18px;font-weight:900;
}
.word-row input{
  flex:1;
  height:46px;
  border:1px solid #d8e4ef;
  border-radius: 16px;
  padding: 0 12px;
  font-size:16px;
}
.send-btn{
  width:46px;height:46px;
  border-radius: 16px;
  border:none;
  background: linear-gradient(90deg, #20c3b6 0%, #3b82f6 100%);
  color:#fff;
  font-size:18px;
  cursor:pointer;
  transition: filter .12s ease, transform .12s ease;
}
.send-btn:hover{
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.feedback{min-height:22px;margin:10px 0 6px 0}

.found-card{
  border:1px solid #e8eff6;
  border-radius: 18px;
  padding: 12px;
  background: #ffffff;
}
.found-header{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom: 8px;
}
.dot{
  width:10px;height:10px;border-radius:999px;
  background: var(--accent);
}
.found-list{
  list-style:none;
  padding:0;
  margin:0;
}
.found-list li{
  padding: 8px 8px 8px 12px;
  border-bottom:1px dashed #e5e7eb;
  display:flex;
  align-items:center;
  gap:10px;
  border-left:6px solid transparent;
}
.found-list li:last-child{border-bottom:none}

.who-dot{
  width:10px;height:10px;border-radius:999px;flex:0 0 auto;
}
.who-name{
  font-size:12px;
  opacity:.7;
  margin-left:auto;
}

.muted{color:var(--muted)}
.rounds-header{display:flex;align-items:center;justify-content:space-between;margin-top:12px}
.round-list{display:flex;flex-direction:column;gap:10px;margin:10px 0 14px 0}
.round-item{
  border:1px solid #e8eff6;
  border-radius: 18px;
  padding: 12px;
  display:flex;gap:12px;align-items:flex-start;
  background:#ffffff;
}
.round-icon{
  width:36px;height:36px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  background:#f2fffd;border:1px solid #d6f5f0;
}
.round-top{display:flex;align-items:center;justify-content:flex-start;gap:8px}
.round-name{font-weight:900}
.round-desc{color:var(--muted);margin-top:4px;font-size:13px}

.badge-diff{
  font-size:12px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid #e8eff6;
  background:#fff;
}
.diff-easy{color:#16a34a}
.diff-mid{color:#ca8a04}
.diff-hard{color:#ea580c}
.diff-boss{color:#dc2626}

.defis-home-card{text-align:center}
.defis-home-icon{
  width:56px;height:56px;border-radius:20px;
  display:flex;align-items:center;justify-content:center;
  margin:0 auto 10px auto;
  background:#fff0d8;
  border:1px solid #f4c784;
  font-size:26px;
}
.defis-home-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  margin-top: 14px;
}
.big-tile{
  border:1px solid #d8e4ef;
  border-radius: 18px;
  padding: 14px;
  background:#fff;
  cursor:pointer;
  display:flex;gap:12px;align-items:center;
  text-align:left;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.big-tile:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  background:#f4f8ff;
}
.tile-icon{
  width:44px;height:44px;border-radius:16px;
  display:flex;align-items:center;justify-content:center;
  font-size:20px;
  border:1px solid #e8eff6;
}
.tile-icon.orange{background:#ffedd5;border-color:#fed7aa}
.tile-icon.cream{background:#f1f5f9}
.tile-title{font-weight:900}
.tile-sub{color:var(--muted);font-size:13px;margin-top:2px}

.form-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
  margin-top: 10px;
}
.field span{display:block;color:var(--muted);font-size:13px;margin-bottom:6px}
.field input{
  width:100%;
  height:46px;
  border:1px solid #d8e4ef;
  border-radius: 16px;
  padding: 0 12px;
  font-size:16px;
}

.section-title{
  font-weight:900;
  margin-top: 14px;
  text-align:left;
}
.choice-row{
  display:flex;
  gap:10px;
  margin-top:10px;
  flex-wrap:wrap;
}
.pill-btn{
  border:1px solid #d8e4ef;
  background:#fff;
  border-radius:999px;
  padding:8px 12px;
  cursor:pointer;
  font-weight:800;
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.pill-btn:hover{
  background:#f4f8ff;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}
.pill-btn.selected{
  border-color: #60a5fa;
  color: #ffffff;
  background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);
}

.code-box{
  border:1px dashed #7aa8c7;
  border-radius: 18px;
  padding: 12px;
  text-align:center;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 6px;
  margin: 12px 0;
  background:#f5fbff;
}

.countdown-card{text-align:center;padding:22px}
.countdown-pill{
  display:inline-block;
  border:1px solid #e8eff6;
  border-radius:999px;
  padding:6px 10px;
  color:var(--muted);
  background:#ffffff;
}
.countdown-number{
  font-size: 72px;
  font-weight: 900;
  margin: 10px 0;
}

.defis-toprow{
  display:flex;
  gap:12px;
  justify-content:space-between;
  align-items:flex-start;
}
.round-title-row{
  display:flex;
  align-items:center;
  gap:10px;
}
.timer-box{
  border:1px solid #e8eff6;
  border-radius: 16px;
  padding: 10px 12px;
  min-width: 130px;
  text-align:right;
  background:#ffffff;
}
.timer-label{color:var(--muted);font-size:12px}
.timer-value{font-weight:900;font-size:22px}

.success-card{text-align:center}
.success-badge{
  display:inline-block;
  border-radius:999px;
  padding:6px 10px;
  border:1px solid #bbf7d0;
  background:#f0fdf4;
  color:#16a34a;
  font-weight:900;
}
.fail-card{text-align:center}
.fail-badge{
  display:inline-block;
  border-radius:999px;
  padding:6px 10px;
  border:1px solid #fecaca;
  background:#fef2f2;
  color:#dc2626;
  font-weight:900;
}

.ready-on{ transform: translateY(-1px); }

@media (max-width: 640px){
  .mode-grid{grid-template-columns: 1fr}
  .defis-home-grid{grid-template-columns: 1fr}
  .alphabet{grid-template-columns: repeat(4, 1fr)}
}
