@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-deep: hsl(222, 47%, 5%);
  --bg-surface: hsl(220, 38%, 10%);
  --bg-surface-hover: hsl(220, 30%, 16%);
  --gold: hsl(42, 93%, 54%);
  --cyan: hsl(190, 82%, 54%);
  --text-primary: hsl(220, 30%, 96%);
  --text-secondary: hsl(220, 20%, 75%);
  --text-muted: hsl(220, 12%, 48%);

  --grad-primary: linear-gradient(135deg, var(--cyan) 0%, var(--gold) 100%);
  --grad-surface: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);

  --glass: rgba(30, 41, 59, 0.4);
  --glass-border: rgba(255, 255, 255, 0.08);
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(at 0% 0%, rgba(34, 211, 238, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(250, 204, 21, 0.12) 0px, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 80px 20px 40px;
}

.game-container {
  max-width: 800px;
  width: 95%;
  background: var(--grad-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 32px;
  padding: 40px;
  box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.5);
  position: relative;
  margin: 0 auto;
  animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 span {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.game-icon-small {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.back-btn {
  padding: 10px 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-5px);
}

/* Modal / Start Screen */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.95);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  text-align: center;
  padding: 40px;
  background: var(--bg-surface);
  border-radius: 32px;
  width: 90%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.input-group {
  margin-bottom: 24px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 4px;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

#startGame {
  width: 100%;
  padding: 16px;
  background: var(--grad-primary);
  color: white;
  border: none;
  border-radius: 16px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 10px 20px -5px rgba(34, 211, 238, 0.3);
}

#startGame:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px rgba(250, 204, 21, 0.3);
}

/* Game Layout */
.game-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
}

.board-area {
  position: relative;
  flex: 0 0 auto;
}

#board {
  width: 250px;
  height: 500px;
  max-width: 100%;
  background: #0a0e1a;
  border: 2px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
  display: block;
}

.side-panel {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 16px;
  text-align: center;
}

.panel-box h3 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#nextCanvas,
#holdCanvas {
  width: 100px;
  height: 100px;
  max-width: 100%;
  background: #0a0e1a;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}

.stats-box {
  text-align: left;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--glass-border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-row strong {
  font-size: 1rem;
  color: var(--gold);
}

.pause-btn {
  width: 100%;
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pause-btn:hover {
  background: var(--bg-surface-hover);
}

.message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.95);
  padding: 30px;
  border-radius: 24px;
  border: 1px solid var(--cyan);
  text-align: center;
  z-index: 500;
  width: 80%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Mobile Controls */
.touch-controls {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin: 24px auto 0;
}

.touch-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-primary);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}

.touch-btn:active {
  background: var(--grad-primary);
  transform: scale(0.95);
}

.hidden {
  display: none !important;
}

@media (max-width: 500px) {
  body {
    padding: 20px 10px;
  }

  .game-container {
    border-radius: 0;
    min-height: 100vh;
    padding: 20px 16px;
  }

  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  #board {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 2;
  }

  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 12px;
  }

  .panel-box {
    flex: 1 1 calc(50% - 12px);
    min-width: 120px;
  }

  .stats-box {
    flex: 1 1 100%;
  }

  #nextCanvas,
  #holdCanvas {
    width: 80px;
    height: 80px;
  }

  .touch-controls {
    display: grid;
  }
}
