* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Suppress the blue flash mobile Chrome paints over a tapped element. */
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #faf8ef;
  color: #5b6470;
  height: 100vh;
  display: flex;
  flex-direction: column;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

h1 {
  font-size: 1.5rem;
  color: #e94560;
}

/* Game Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  background: #faf8ef;
  border-bottom: 1px solid #e7e2d3;
}

.back-link {
  color: #5b6470;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: bold;
  padding: 6px 12px;
  background: #efe9d8;
  border-radius: 6px;
  transition: background 0.2s;
}

.back-link:hover {
  background: #e4dcc4;
}

.score-container {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.score-box {
  background: #efe9d8;
  border-radius: 6px;
  padding: 4px 10px;
  text-align: center;
}

.score-label {
  display: block;
  font-size: 0.55rem;
  color: #a89e84;
  text-transform: uppercase;
  font-weight: bold;
}

#score, #lives, #level {
  display: block;
  font-size: 1.1rem;
  font-weight: bold;
  color: #e94560;
}

.restart-btn {
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.restart-btn:hover {
  background: #c73650;
}

/* Game Area */
#game-area-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #faf8ef;
}

.game-area {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  transition: transform 0.1s ease;
}

.grid-container {
  display: grid;
  background: transparent;
}

.grid-cell {
  width: 100%;
  height: 100%;
}

/* A subtle dot marks every cell where an arrow segment can rest. */
.grid-cell.dot {
  background: radial-gradient(circle at 50% 50%, #cdd2dc 0, #cdd2dc 2.4px, transparent 2.8px);
}

.arrow-container {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Arrow wrappers */
.arrow-wrapper {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}

.arrow-svg {
  pointer-events: none;
  display: block;
  cursor: pointer;
  overflow: visible;
  transition: filter 0.2s;
}

.arrow-svg:hover {
  filter: brightness(1.15);
}

.arrow-line,
.arrow-head {
  pointer-events: none;
}

.arrow-hit {
  pointer-events: all;
  cursor: pointer;
}

/* Game Over / Win overlays */
.game-over {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(250, 248, 239, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.game-over p {
  font-size: 2.5rem;
  font-weight: bold;
  color: #e94560;
  margin-bottom: 20px;
}

.hidden {
  display: none;
}
