@import 'https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap';

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#app {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 900px;
  width: 100%;
}

/* ── Game panel ── */
#game-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#game-panel h1 {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.5px;
}

#canvas-container canvas {
  display: block;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── Control panel ── */
#control-panel {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Theme selector */
#theme-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-btn {
  padding: 10px 8px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.theme-btn:hover { background: rgba(255,255,255,0.22); transform: scale(1.04); }
.theme-btn.active {
  background: rgba(255,255,255,0.3);
  border-color: #FFE066;
  color: #FFE066;
}

/* Command queue */
#queue-box {
  background: rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  min-height: 90px;
}

#queue-box h3 {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  opacity: 0.7;
}

#queue-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  align-items: flex-start;
}

.queue-hint {
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
  font-style: italic;
  align-self: center;
}

.cmd-card {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
}
.cmd-card:hover { background: rgba(255,80,80,0.4); transform: scale(1.1); }
.cmd-card.active {
  background: #FFE066;
  box-shadow: 0 0 0 3px rgba(255,224,102,0.5);
  transform: scale(1.15);
}

/* D-pad */
#dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dir-btn {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dir-btn:hover:not(:disabled) { background: rgba(255,255,255,0.32); transform: scale(1.08); }
.dir-btn:active:not(:disabled) { transform: scale(0.95); }

#clear-btn {
  background: rgba(255,100,100,0.25);
  font-size: 1.4rem;
}
#clear-btn:hover:not(:disabled) { background: rgba(255,80,80,0.45); }

/* GO button */
#go-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: #fff;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(0,184,148,0.4);
  letter-spacing: 1px;
}
#go-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,184,148,0.55);
}
#go-btn:active:not(:disabled) { transform: translateY(0); }
#go-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal ── */
#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#modal.hidden { display: none; }

#modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}

#modal-content {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 36px 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 16px 60px rgba(0,0,0,0.4);
  animation: popIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

#modal-title {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 12px;
  color: #2d3436;
}

#modal-message {
  font-size: 1.05rem;
  color: #636e72;
  margin-bottom: 24px;
  line-height: 1.5;
}

#modal-close {
  padding: 12px 32px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 16px rgba(108,92,231,0.4);
}
#modal-close:hover { transform: scale(1.06); box-shadow: 0 6px 20px rgba(108,92,231,0.55); }

/* ── Responsive ── */
@media (max-width: 680px) {
  #app { flex-direction: column; align-items: center; }
  #control-panel { min-width: unset; width: 100%; max-width: 400px; }
}

/* ── Difficulty selector ── */
#difficulty-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.diff-label {
  color: rgba(255,255,255,0.55);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.diff-btn {
  flex: 1;
  padding: 7px 4px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.diff-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.04); }
.diff-btn[data-diff="easy"].active   { border-color: #00b894; color: #00b894; background: rgba(0,184,148,0.18); }
.diff-btn[data-diff="medium"].active { border-color: #fdcb6e; color: #fdcb6e; background: rgba(253,203,110,0.18); }
.diff-btn[data-diff="hard"].active   { border-color: #e17055; color: #e17055; background: rgba(225,112,85,0.18); }
