/* Tetris • bukanlah.my.id — modern dark theme */
:root {
  --bg-0: #070a14;
  --bg-1: #0d1224;
  --bg-2: #131a35;
  --panel: rgba(20, 26, 56, 0.65);
  --panel-edge: rgba(120, 160, 255, 0.18);
  --text: #e6ecff;
  --muted: #8590b8;
  --accent: #00e5ff;
  --accent-2: #ff4081;
  --good: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: 0 10px 40px rgba(0, 229, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.6);
  --grid-line: rgba(120, 160, 255, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(0, 229, 255, 0.08), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, rgba(255, 64, 129, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 60%, var(--bg-0));
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 18px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
  margin: 0; font-size: 22px; letter-spacing: 2px; font-weight: 800;
  background: linear-gradient(90deg, #fff, #b3c8ff 60%, #6ea8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .dim { color: var(--muted); font-weight: 600; }
.logo {
  width: 32px; height: 32px; display: grid; grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  gap: 2px; transform: rotate(45deg);
}
.logo .b { border-radius: 3px; box-shadow: 0 0 8px currentColor; }
.b1 { background: var(--accent); color: var(--accent); }
.b2 { background: #ffd166; color: #ffd166; }
.b3 { background: var(--accent-2); color: var(--accent-2); }
.b4 { background: #6ee7b7; color: #6ee7b7; }

.domain-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.4px; color: var(--muted);
  padding: 6px 10px; border: 1px solid var(--panel-edge);
  background: var(--panel); border-radius: 999px; backdrop-filter: blur(6px);
}
.domain-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 8px var(--good);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; transform: scale(0.85); } }

/* ---------- Stage ---------- */
.stage {
  display: grid;
  grid-template-columns: 220px auto 240px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 920px) {
  .stage { grid-template-columns: 1fr; }
  .side.left, .side.right { order: 2; }
  .board-wrap { order: 1; }
}

.side { display: flex; flex-direction: column; gap: 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.panel h3 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: 2px;
  color: var(--muted); text-transform: uppercase; font-weight: 700;
}
.panel canvas { display: block; margin: 0 auto; background: #06091a; border-radius: 8px; }

/* Stats */
.stat {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px dashed rgba(120,160,255,0.1);
  font-size: 14px;
}
.stat:last-child { border-bottom: 0; }
.stat span { color: var(--muted); font-size: 12px; letter-spacing: 0.5px; }
.stat b { font-variant-numeric: tabular-nums; font-size: 18px; }

/* Keys */
.keys { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.keys li { display: flex; align-items: center; gap: 6px; }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 2px 6px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  color: var(--text); background: #111633; border: 1px solid rgba(120,160,255,0.2);
  border-bottom-width: 2px; border-radius: 6px;
}

/* Leaderboard */
.leaderboard { list-style: none; padding: 0; margin: 0 0 8px; max-height: 180px; overflow-y: auto; }
.leaderboard li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; font-size: 13px; border-radius: 6px; margin-bottom: 2px;
  background: rgba(0, 229, 255, 0.04);
}
.leaderboard li.me { background: rgba(0, 229, 255, 0.12); border: 1px solid rgba(0,229,255,0.3); }
.leaderboard li b { font-weight: 700; color: var(--accent); }
.leaderboard li .rank { color: var(--muted); margin-right: 8px; min-width: 22px; }
.leaderboard .empty { color: var(--muted); font-style: italic; padding: 6px 8px; }

/* ---------- Board ---------- */
.board-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.board-shadow {
  position: relative;
  padding: 8px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(0,229,255,0.15), rgba(255,64,129,0.1));
  box-shadow: var(--shadow);
}
#board {
  display: block;
  background: #04060f;
  border-radius: 10px;
  border: 1px solid rgba(120, 160, 255, 0.15);
  width: min(80vw, 300px);
  height: min(160vw, 600px);
  touch-action: none;
}
.touch-hint { font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }

/* Overlay */
.overlay {
  position: absolute; inset: 8px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 15, 0.78);
  backdrop-filter: blur(4px);
  transition: opacity 0.2s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-card {
  text-align: center; padding: 18px 22px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 14px; min-width: 240px;
}
.overlay-card h2 { margin: 0 0 6px; font-size: 22px; }
.overlay-card p  { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.overlay-card .primary { display: inline-block; }
.overlay-card .ghost { display: inline-block; margin-left: 8px; }

/* Buttons */
button { font: inherit; cursor: pointer; }
.primary, .ghost {
  padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
}
.primary {
  background: linear-gradient(180deg, #00e5ff, #00b3cc);
  color: #001220; border: 0; box-shadow: 0 4px 18px rgba(0, 229, 255, 0.3);
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(0, 229, 255, 0.45); }
.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--panel-edge);
}
.ghost:hover { background: rgba(0, 229, 255, 0.08); }
.ghost.small { padding: 5px 10px; font-size: 11px; margin-top: 4px; }

/* Touch pad */
.touch-pad {
  position: fixed; left: 0; right: 0; bottom: 10px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  padding: 8px 10px; z-index: 5;
}
.touch-pad button {
  padding: 14px 0; font-size: 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  color: var(--text); backdrop-filter: blur(8px);
}
.touch-pad button:active { background: rgba(0, 229, 255, 0.18); transform: scale(0.96); }
@media (min-width: 921px) { .touch-pad { display: none; } }
@media (max-width: 920px) { .touch-pad { display: grid; } }

/* Footer */
.foot {
  margin-top: 16px; padding: 8px 0; text-align: center;
  font-size: 11px; color: var(--muted); letter-spacing: 0.5px;
}
.foot a { color: var(--accent); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 10;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  max-width: 420px; width: 100%; background: var(--panel);
  border: 1px solid var(--panel-edge); border-radius: 16px; padding: 20px 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.modal-card h2 { margin: 0 0 10px; }
.modal-card ol { padding-left: 18px; line-height: 1.6; }
.modal-card .muted { color: var(--muted); font-size: 12px; }
.modal-card .primary { margin-top: 12px; }

/* Flash animation when scoring */
@keyframes flash {
  0% { background-color: rgba(0, 229, 255, 0.4); }
  100% { background-color: transparent; }
}
.flash { animation: flash 0.3s ease-out; }
