:root {
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-400: #2dd4bf;
  --teal-100: #ccfbf1;
  --teal-050: #f0fdfa;
  --ink: #0f3d3a;
  --muted: #5f7d7a;
  --glass: rgba(255,255,255,.62);
  --glass-strong: rgba(255,255,255,.82);
  --stroke: rgba(255,255,255,.9);
  --stroke-teal: rgba(13,148,136,.16);
  --shadow-sm: 0 4px 18px rgba(13,148,136,.08);
  --shadow-md: 0 14px 44px rgba(13,148,136,.14);
  --radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.ic { display: inline-flex; align-items: center; justify-content: center; vertical-align: -3px; }
.logo .luc { color: #fff; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 88% -8%, rgba(45,212,191,.20), transparent 62%),
    radial-gradient(900px 520px at -8% 34%, rgba(153,246,228,.38), transparent 58%),
    linear-gradient(180deg, #f6fdfb 0%, #eefaf7 100%);
  display: flex; flex-direction: column; align-items: center; overflow: hidden;
}
.hidden { display: none !important; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(13,148,136,.28); border-radius: 999px; }
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.deco { position: absolute; border-radius: 50%; filter: blur(72px); }
.d1 { width: 480px; height: 480px; top: -170px; left: -130px; background: radial-gradient(circle, rgba(45,212,191,.42), transparent 70%); }
.d2 { width: 400px; height: 400px; bottom: -150px; right: -110px; background: radial-gradient(circle, rgba(153,246,228,.5), transparent 70%); }
.d3 { width: 240px; height: 240px; top: 36%; left: 60%; background: radial-gradient(circle, rgba(240,253,250,.95), transparent 70%); }
.ring { width: 360px; height: 360px; top: 10%; right: 5%; border: 1.6px dashed rgba(20,184,166,.26); filter: none; }
.dots { position: absolute; width: 130px; height: 130px; top: 22%; left: 10%; background-image: radial-gradient(rgba(13,148,136,.38) 1.6px, transparent 1.6px); background-size: 15px 15px; filter: none; opacity: .55; }

.page { position: relative; z-index: 1; width: 100%; max-width: 980px; height: 100vh; display: flex; flex-direction: column; }
header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div { min-width: 0; }
.brand-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
sup { font-size: .5em; top: -1.2em; }
.logo {
  width: 44px; height: 44px; border-radius: 15px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
  box-shadow: 0 8px 20px rgba(13,148,136,.35);
}
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-en { font-size: 11px; color: var(--muted); letter-spacing: 1.2px; font-weight: 500; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn {
  height: 40px; padding: 0 14px; flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid rgba(13,148,136,.28); border-radius: 14px;
  background: rgba(255,255,255,.72); color: var(--teal-700);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.back-btn .luc { width: 16px; height: 16px; }

.announce {
  margin: 10px 16px 0;
  padding: 11px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(204,251,241,.95), rgba(240,253,250,.9));
  border: 1px solid rgba(13,148,136,.22);
  color: var(--teal-700);
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}
.announce::before {
  content: "";
  display: inline-block;
  width: 16px; height: 16px;
  margin-right: 7px;
  vertical-align: -2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.268 21a2 2 0 0 0 3.464 0'/%3E%3Cpath d='M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.268 21a2 2 0 0 0 3.464 0'/%3E%3Cpath d='M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326'/%3E%3C/svg%3E") center/contain no-repeat;
}

main { flex: 1; overflow-y: auto; padding: 18px 16px 20px; }
.gallery { max-width: 760px; margin: 0 auto; }
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { font-size: 24px; font-weight: 800; letter-spacing: 1px; }
.hero p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .games-grid { grid-template-columns: 1fr; } }
.card {
  display: flex; flex-direction: column; gap: 9px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s, box-shadow .2s;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  position: relative;
}
button.card { font-size: inherit; }
.card:active { transform: scale(.98); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-icon {
  width: 44px; height: 44px; flex: none; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
  box-shadow: 0 8px 18px rgba(13,148,136,.28);
}
.card.explore .card-icon { background: linear-gradient(135deg, #0d9488, #6366f1); }
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--teal-700);
  background: rgba(240,253,250,.85); border: 1px solid var(--stroke-teal);
  white-space: nowrap;
}
.card .name { font-size: 17px; font-weight: 700; }
.card .desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.card-foot { margin-top: 2px; font-size: 12px; color: var(--teal-700); font-weight: 600; }
.sheen { position: relative; overflow: hidden; }
.sheen::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(130px circle at var(--x,50%) var(--y,50%), rgba(255,255,255,.5), rgba(255,255,255,0) 62%);
  opacity: 0; transition: opacity .25s ease; pointer-events: none;
}
.sheen:hover::before { opacity: 1; }
button.sheen, a.sheen {
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
}
button.sheen:hover:not(:disabled), a.sheen:hover { transform: translateY(-1px) scale(1.02); }
button.sheen:active:not(:disabled), a.sheen:active { transform: scale(.95); }

.room { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.room[hidden] { display: none; }
.room-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--stroke-teal); border-radius: 14px;
  background: rgba(255,255,255,.72); color: var(--teal-700);
  cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.icon-btn .luc { width: 18px; height: 18px; }
.room-title { flex: 1; min-width: 0; }
.room-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.score-box {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 12px; border-radius: 13px;
  background: rgba(240,253,250,.85); border: 1px solid var(--stroke-teal);
  min-width: 64px;
}
.score-label { font-size: 10px; color: var(--muted); letter-spacing: .5px; }
.score-value { font-size: 15px; font-weight: 800; color: var(--teal-700); font-variant-numeric: tabular-nums; }
.room-actions { display: flex; gap: 10px; }
.ghost-btn {
  height: 40px; padding: 0 16px;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid rgba(13,148,136,.28); border-radius: 14px;
  background: rgba(255,255,255,.72); color: var(--teal-700);
  font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm); font-family: inherit;
}
.ghost-btn .luc { width: 16px; height: 16px; }

.stage {
  width: 100%; max-width: 500px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 16px 14px 18px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.game-canvas {
  display: block; border-radius: 16px;
  background: rgba(240,253,250,.5);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.08);
  touch-action: none;
}
.game-overlay {
  position: fixed;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 30;
  padding: 14px 26px;
  border-radius: 999px;
  background: rgba(15,61,58,.88); color: #fff;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 14px 40px rgba(13,148,136,.35);
}
.game-pad {
  width: 168px; height: 168px; flex: none;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 8px;
}
.pad-btn {
  border: 1px solid var(--stroke-teal); border-radius: 14px;
  background: rgba(255,255,255,.78); color: var(--teal-700);
  font-size: 18px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, background .15s;
  touch-action: manipulation;
}
.pad-btn:not(:disabled):active { transform: scale(.94); background: rgba(204,251,241,.9); }
.pad-btn:disabled { opacity: 0; pointer-events: none; }

.tetris-panel { display: flex; gap: 12px; align-items: flex-start; justify-content: center; }
.tetris-side { display: flex; flex-direction: column; gap: 10px; min-width: 96px; }
.next-canvas {
  display: block; border-radius: 12px;
  background: rgba(240,253,250,.5);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.08);
}
.tetris-stats {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.tetris-stats b { color: var(--teal-700); font-size: 14px; }
.tetris-controls { display: flex; gap: 8px; align-items: center; }
.tetris-controls .game-pad { width: 150px; height: 150px; }
.pad-action { min-width: 54px; font-size: 15px; }
@media (max-width: 560px) {
  .back-text { display: none; }
  .back-btn { width: 40px; padding: 0; justify-content: center; }
  .room-head { flex-wrap: wrap; }
  .score-box { min-width: 56px; padding: 6px 9px; }
  .stage { padding: 12px 10px 14px; }
}

footer {
  padding: 10px 16px;
  text-align: center;
  font-size: 11px;
  color: #9ab0ad;
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--stroke);
}
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(15,61,58,.88); backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 13px;
  max-width: 86%; z-index: 99; display: none;
  box-shadow: 0 10px 30px rgba(13,148,136,.35);
  border: 1px solid rgba(255,255,255,.2);
}

/* ---- Leaderboard ---- */
.leaderboard-section {
  margin-top: 24px;
  padding: 0 0 20px;
}
.lb-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
}
.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.lb-tab {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.lb-tab.active {
  background: rgba(13,148,136,.25);
  color: var(--teal-700);
  border-color: rgba(13,148,136,.4);
}
.lb-list {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}
.lb-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.lb-table {
  width: 100%;
  border-collapse: collapse;
}
.lb-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid rgba(13,148,136,.16);
  font-weight: 600;
}
.lb-table td {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid rgba(13,148,136,.08);
}
.lb-table tr:last-child td {
  border-bottom: none;
}
.lb-rank { width: 44px; text-align: center; }
.lb-name { color: var(--muted); }
.lb-score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--teal-700); }

/* ---- Score Submit Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-card {
  background: #0f3d3a;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 28px 24px;
  width: 320px;
  max-width: 90vw;
  text-align: center;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 12px;
}
.modal-score {
  font-size: 22px;
  font-weight: 800;
  color: #5eead4;
  margin-bottom: 16px;
}
.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}
.modal-input::placeholder { color: #6b8a85; }
.modal-input:focus { border-color: rgba(13,148,136,.6); }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-btn {
  padding: 8px 24px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.modal-btn.cancel {
  background: rgba(255,255,255,.08);
  color: #9ab0ad;
}
.modal-btn.cancel:hover { background: rgba(255,255,255,.14); }
.modal-btn.submit {
  background: rgba(13,148,136,.4);
  color: #5eead4;
}
.modal-btn.submit:hover { background: rgba(13,148,136,.55); }
.modal-btn:disabled { opacity: .5; cursor: not-allowed; }
.modal-result {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}
