html, body, #page-wrapper {
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  background: #222;
  color: #fff;
  font-family: 'Segoe UI', Arial, sans-serif;
  min-height: 100vh;
  width: 100vw;
}

.container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  min-height: 100vh;
  justify-content: flex-start;
  padding-top: 2rem;
}

header {
  margin-bottom: 1rem;
  text-align: center;
}

.scoreboard {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 0.5rem;
}


main {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  justify-content: center;
}

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


/* Responsive canvas sizing: shrink to fit viewport on small screens */
#game {
  background: #333;
  border: 4px solid #444;
  border-radius: 8px;
  display: block;
  margin-bottom: 1rem;
  max-width: 90vw;
  height: auto;
  max-height: calc(100vh - 16rem); /* leave more space for header, controls, next piece, etc. */
  aspect-ratio: 1/2;
}

/* Controls fill canvas width and use dark gray/white */
.controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 300px;
}
.controls button {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 6px;
  flex: 1 1 0;
  padding: 0.7em 0;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
  min-width: 0;
}
.controls button:active {
  background: #666;
}

#restart {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.7em 1.2em;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 1rem;
}
#restart:active {
  background: #666;
}

.next-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#next {
  background: #333;
  border: 2px solid #444;
  border-radius: 4px;
  margin-top: 0.5rem;
}

#game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(34, 34, 34, 0.95);
  padding: 2rem 3rem;
  border-radius: 12px;
  text-align: center;
  z-index: 10;
}

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

/* Tetromino colors */
.tetromino-I { background: #00f0f0; }
.tetromino-O { background: #f0f000; }
.tetromino-T { background: #a000f0; }
.tetromino-S { background: #00f000; }
.tetromino-Z { background: #f00000; }
.tetromino-J { background: #0000f0; }
.tetromino-L { background: #f0a000; }

@media (max-width: 600px) {
  main {
    flex-direction: column;
    align-items: center;
  }
  .game-area {
    width: 100vw;
    align-items: center;
  }
  #game {
    width: 90vw;
    height: auto;
    aspect-ratio: 1/2;
    max-width: 300px;
    max-height: calc(100vh - 16rem);
    margin-bottom: 1rem;
  }
  #next {
    width: 60px;
    height: 60px;
  }
}
