:root {
    --bg: #0f172a;
    --panel: #0b1226;
    --grid: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --good: #34d399;
    --bad: #f87171;
    --pc: 18px;
    --gap: 6px
}* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: linear-gradient(180deg, #0b1022, #0f172a);
  color: var(--text);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}
.wrap {
  width: min(1100px, 96vw);
  padding: 28px 16px 40px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
h1 {
  font-size: clamp(18px, 2vw, 22px);
  margin: 0;
  font-weight: 700;
}
.score {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.badge {
  padding: 6px 10px;
  border-radius: 10px;
  background: #0b1226;
  border: 1px solid #1f2a44;
  color: var(--text);
  font-weight: 700;
}

.board-area {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.grid {
  position: relative;
  width: min(520px, 86vw);
  aspect-ratio: 1/1;
  background: var(--grid);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: var(--gap);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 1px #243048;
}
.cell {
  background: #0c1226;
  border-radius: 8px;
  position: relative;
}
.cell.fill {
  background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.15),
      rgba(255, 255, 255, 0.02)
    ),
    var(--c, #64748b);
}
.ghost-ok {
  outline: 2px dashed var(--good);
  outline-offset: -2px;
}
.ghost-bad {
  outline: 2px dashed var(--bad);
  outline-offset: -2px;
}
.hint {
  outline: 2px dashed #fbbf24;
  outline-offset: -2px;
}

.pieces {
  flex: 1;
  min-width: 280px;
  background: var(--panel);
  border: 1px solid #1f2a44;
  border-radius: 14px;
  padding: 14px;
}
.pieces h3 {
  margin: 6px 8px 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}
.rack {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.piece {
  background: #0e1530;
  border: 1px solid #243048;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 4px;
  cursor: grab;
  user-select: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}
.piece:active {
  cursor: grabbing;
}
.p-cell {
  width: var(--pc);
  height: var(--pc);
  border-radius: 5px;
  background: var(--c, #60a5fa);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35)
}
button {
  background: #0f1a36;
  color: var(--text);
  border: 1px solid #243048;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#board,
.rack,
.piece {
  touch-action: none;
}
/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.open {
  display: flex;
}
.card {
  width: min(460px, 92vw);
  background: #0c1226;
  border: 1px solid #243048;
  border-radius: 14px;
  padding: 16px;
}
.card h3 {
  margin: 0 0 10px;
}
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px dashed #243048;
  border-radius: 8px;
}
.list li.me {
  background: #1e3a8a;
  color: #fff;
  font-weight: 700;
}

.input {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #243048;
  background: #0f1a36;
  color: var(--text);
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.35));
  z-index: 60;
  display: grid;
  gap: 4px;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
}
@keyframes pop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
  100% {
    transform: scale(0.6);
    opacity: 0;
  }
}
.cell.clear-pop {
  animation: pop 0.22s ease forwards;
}

/* Responsive */
@media (max-width: 1024px){
  .board-area{gap:16px}
  .pieces{min-width:unset;width:100%}
}

@media (max-width: 700px){
  :root{--pc:14px;--gap:4px}
  .wrap{padding:20px 10px 28px}
  .grid{width:96vw;padding:8px}
  .piece{padding:8px}
  button{width:100%}     /* nút dễ bấm hơn */
  .score{gap:8px}
  .card{width:96vw}      /* modal full hơn trên mobile */
}