* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #1a1a1a;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  height: 100dvh;
  padding: 16px;
  gap: 24px;
}

#level-number {
  font-size: 18px;
  color: #666;
  font-weight: 600;
}

/* Grid area */
#grid-container {
  position: relative;
  touch-action: none;
  flex-shrink: 0;
}

#grid-background {
  position: absolute;
  inset: 0;
  background: #2a2a2a;
  border-radius: 12px;
}

#grid-cells {
  position: relative;
  display: grid;
  gap: var(--tile-gap);
  padding: var(--grid-padding);
}

.cell {
  width: var(--tile-size);
  height: var(--tile-size);
  background: #333333;
  border-radius: 8px;
}

/* Game tiles overlay */
#tile-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: 8px;
  transition: transform var(--anim-duration) linear;
}

.tile.combined {
  transition: transform var(--anim-duration) linear,
              opacity var(--anim-duration) linear;
  opacity: 0;
}

/* Move queue area */
#move-queue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

#arrows {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  align-items: center;
}

.arrow {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
}

.arrow svg {
  width: 100%;
  height: 100%;
}

/* Buttons */
#buttons {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  color: #fff;
}

.btn:active {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn-play {
  background: #44bb44;
}

.btn-clear {
  background: #555;
}

.btn-reset {
  background: #bb4444;
}

/* Win overlay */
#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  z-index: 100;
}

#win-overlay.visible {
  display: flex;
}

#win-overlay h1 {
  font-size: 48px;
  color: #44ff44;
}

#win-overlay .move-count {
  font-size: 24px;
  color: #ccc;
}
