/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #87cefa;
  font-family: 'Raleway', sans-serif;
}

/* ---- Full-viewport game wrapper (portrait-first) ---- */
#game-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 6px;
  gap: 4px;
}

/* ---- Header / HUD ---- */
#game-header {
  text-align: center;
  flex-shrink: 0;
}

#game-header h1 {
  font-size: 1.5rem;
  font-weight: bold;
  color: #222;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1.2;
}

#hud {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: #333;
  margin-top: 2px;
}

#hud select {
  height: 22px;
  width: 52px;
  font-size: 0.72rem;
  border: 1.5px solid #e05;
  border-radius: 3px;
  vertical-align: middle;
}

/* ---- Canvas container ---- */
#canvas-container {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #87cefa;
  min-height: 0;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Width/height set by JS; CSS transform scale applied by scaleCanvas() */
}

/* ---- Action buttons ---- */
#action-buttons {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.action-btn {
  cursor: pointer;
  padding: 6px 10px;
  background-color: #FF8784;
  border: 2px dashed #fff;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  font-family: 'Raleway', sans-serif;
  color: #222;
  min-width: 60px;
  touch-action: manipulation;
  user-select: none;
}

.action-btn:hover, .action-btn:active {
  background-color: #6CDB7F;
}

.action-btn:focus { outline: none; }

/* ---- D-pad ---- */
#dpad {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 4px;
}

#dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 4px;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  font-size: 1.4rem;
  cursor: pointer;
  background: rgba(0,0,0,0.18);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  font-family: sans-serif;
}

.dpad-btn:active {
  background: rgba(108, 219, 127, 0.7);
  transform: scale(0.93);
}

.dpad-center {
  background: rgba(0,0,0,0.08);
  border-radius: 50%;
  width: 60px;
  height: 60px;
}

/* ---- jQuery UI dialog overrides ---- */
.ui-dialog {
  max-width: 95vw !important;
}

.ui-dialog-content {
  text-align: center;
}

#dialog h3 {
  font-size: 1.1rem;
  padding: 10px;
  color: #222;
}

.no-close .ui-dialog-titlebar-close {
  display: none;
}

/* ---- Landscape override: side-by-side ---- */
@media (orientation: landscape) and (min-width: 600px) {
  #game-wrapper {
    flex-direction: row;
    max-width: 100%;
    align-items: stretch;
  }

  #canvas-container {
    flex: 1 1 auto;
  }

  #game-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 160px;
  }
}
