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

html, body {
  height: 100%;
  background: #0a0a14;
  color: #e8e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  gap: 8px;
}

#game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
}

#field-wrap {
  position: relative;
  height: 100%;
  aspect-ratio: 1 / 2;
  max-width: 100%;
}

#field-canvas {
  width: 100%;
  height: 100%;
  background: #16162a;
  border: 2px solid #2a2a44;
  border-radius: 4px;
  display: block;
}

#side-left, #side-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  justify-content: flex-start;
}

.panel {
  background: #16162a;
  border: 1px solid #2a2a44;
  border-radius: 4px;
  padding: 6px 10px;
  min-width: 80px;
}

.panel-label {
  font-size: 10px;
  color: #8888aa;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.panel-value {
  font-size: 18px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#next-canvas {
  width: 80px;
  height: 80px;
  display: block;
}

#controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 480px;
}

.ctrl-btn {
  background: #1f1f3a;
  color: #e8e8f0;
  border: 1px solid #3a3a5a;
  border-radius: 8px;
  font-size: 22px;
  font-weight: bold;
  padding: 14px 0;
  cursor: pointer;
  touch-action: manipulation;
}

.ctrl-btn:active {
  background: #2a2a4a;
  transform: scale(0.96);
}

.ctrl-wide {
  grid-column: span 4;
  font-size: 16px;
  letter-spacing: 2px;
}

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 4px;
}

#overlay.hidden {
  display: none;
}

#overlay-text {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  text-align: center;
}

#start-btn {
  background: #4a4aff;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 18px;
  font-weight: bold;
  padding: 12px 28px;
  cursor: pointer;
  letter-spacing: 2px;
}

#start-btn:active {
  background: #3a3acc;
}

@media (min-width: 768px) and (pointer: fine) {
  #controls {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #app {
    flex-direction: row;
  }
  #controls {
    grid-template-columns: repeat(2, 1fr);
    width: auto;
    height: 100%;
  }
  .ctrl-wide {
    grid-column: span 2;
  }
}
