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

body {
  font-family: 'Segoe UI', sans-serif;
  background: #f0f0f5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

#app {
  width: 100%;
  max-width: 900px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 8px;
}

h1 {
  font-size: 2rem;
  letter-spacing: 2px;
  color: #333;
}

#info-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 1.1rem;
  color: #444;
}

#new-game-btn, #play-again-btn {
  padding: 8px 18px;
  background: #5b4fcf;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

#new-game-btn:hover, #play-again-btn:hover {
  background: #4438b0;
}

#message-bar {
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: opacity 0.4s;
}

#message-bar.hidden { visibility: hidden; }
#message-bar.success { background: #d4edda; color: #155724; visibility: visible; }
#message-bar.error   { background: #f8d7da; color: #721c24; visibility: visible; }

/* Board */
#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

/* Card */
.card {
  background: white;
  border: 3px solid #ccc;
  border-radius: 14px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 7 / 5;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  user-select: none;
}

.card:hover {
  border-color: #aaa;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.card.selected {
  border-color: #5b4fcf;
  box-shadow: 0 0 0 3px #b9b0f5;
  transform: translateY(-3px);
}

/* SVG shapes */
svg.shape {
  width: 56px;
  height: 28px;
  display: block;
  transform: rotate(90deg);
}

svg.shape.squiggle {
  transform: rotate(90deg) scaleX(-1);
}

/* Colors */
.red    { stroke: #e03030; fill: #e03030; }
.green  { stroke: #2a9a2a; fill: #2a9a2a; }
.purple { stroke: #7b30c8; fill: #7b30c8; }

/* Shadings */
.open   { fill: none; }
.solid  { fill-opacity: 1; }
.striped { fill: url(#stripe-red); }
.striped.green  { fill: url(#stripe-green); }
.striped.purple { fill: url(#stripe-purple); }

/* Game over overlay */
#game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#game-over-overlay.hidden { display: none; }

#game-over-box {
  background: white;
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

#game-over-box h2 {
  font-size: 2rem;
  margin-bottom: 12px;
  color: #333;
}

#game-over-box p {
  font-size: 1.3rem;
  margin-bottom: 24px;
  color: #555;
}

@media (max-width: 600px) {
  #board {
    grid-template-columns: repeat(3, 1fr);
  }
  svg.shape {
    width: 44px;
    height: 22px;
  }
}
