* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #000000;
  color: #d9ffd0;
  font-family: system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hud__item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__value {
  font-family: "Silkscreen", ui-monospace, "Courier New", monospace;
  font-size: 26px;
  font-weight: 700;
  color: #39ff14;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.55);
  font-variant-numeric: tabular-nums;
}

.hud__button {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 38px;
  padding: 0;
  color: #39ff14;
  background: #061006;
  border: 2px solid #2bff2b;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 #123f12;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.hud__icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.hud__icon--play {
  display: none;
}

.hud__button.is-play .hud__icon--pause {
  display: none;
}

.hud__button.is-play .hud__icon--play {
  display: block;
}

.hud__button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 #123f12;
}

.hud__button:disabled {
  opacity: 0.45;
  cursor: default;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.stage__board {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  background: #0b0f0b;
  border-radius: 6px;
  box-shadow: 0 0 0 3px #1f4d1f, 0 0 22px rgba(57, 255, 20, 0.25);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 6px;
}

.overlay.is-hidden {
  display: none;
}

.overlay__title {
  margin: 0;
  font-family: "Silkscreen", ui-monospace, "Courier New", monospace;
  font-size: 24px;
  font-weight: 700;
  color: #39ff14;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.5);
}

.overlay__text {
  margin: 0;
  max-width: 22em;
  font-size: 14px;
  line-height: 1.5;
  color: #9fbfa0;
}

.overlay__status:empty {
  display: none;
}

.overlay__button {
  padding: 12px 30px;
  font-size: 18px;
  font-weight: 700;
  color: #041204;
  background: #39ff14;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1c7a10, 0 0 18px rgba(57, 255, 20, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.overlay__button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #1c7a10;
}

.overlay__modes {
  display: flex;
  gap: 8px;
}

.overlay__modes .overlay__button {
  padding: 8px 16px;
  font-size: 14px;
  color: #22303a;
  background: #ffffff;
  border: 1px solid #d7e2db;
}

.overlay__modes .overlay__button.is-active {
  color: #ffffff;
  background: #2e9e63;
  border-color: #2e9e63;
}

.controls {
  display: none;
  justify-content: center;
}

/* 방향 버튼은 터치 기기(모바일)에서만 보여 줍니다. */
@media (hover: none) and (pointer: coarse) {
  .controls {
    display: flex;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 44px);
  gap: 6px;
  touch-action: manipulation;
}

.dpad__button {
  font-size: 18px;
  font-weight: 700;
  color: #39ff14;
  background: #061006;
  border: 2px solid #2bff2b;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 #123f12;
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.06s ease;
}

.dpad__button:active {
  transform: translateY(3px);
  background: #0d240d;
  box-shadow: 0 0 0 #123f12;
}

.dpad__button--up {
  grid-area: 1 / 2;
}

.dpad__button--left {
  grid-area: 2 / 1;
}

.dpad__button--down {
  grid-area: 3 / 2;
}

.dpad__button--right {
  grid-area: 2 / 3;
}

.hud__button:focus-visible,
.overlay__button:focus-visible,
.dpad__button:focus-visible {
  outline: 2px solid #39ff14;
  outline-offset: 2px;
}

@media (max-height: 620px) {
  .dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 36px);
  }
}
