* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #2c5a29;
  color: #e8ecf5;
  font-family: system-ui, "Malgun Gothic", sans-serif;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#game {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: block;
  background: #4c9a3f;
  touch-action: none;
}

.pad {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(2, 54px);
  gap: 6px;
  opacity: 0.9;
}

.pad-btn {
  border: 1px solid #3d4a66;
  border-radius: 10px;
  background: rgba(38, 47, 68, 0.85);
  color: #e8ecf5;
  font-size: 18px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.pad-btn:active,
.pad-btn.is-down {
  background: #4b7bd6;
}

.pad-btn[data-dir="up"] { grid-column: 2; grid-row: 1; }
.pad-btn[data-dir="left"] { grid-column: 1; grid-row: 2; }
.pad-btn[data-dir="down"] { grid-column: 2; grid-row: 2; }
.pad-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }

.attack-btn {
  position: absolute;
  right: 14px;
  bottom: 58px;
  width: 70px;
  height: 70px;
  border: 2px solid #f2c6d6;
  border-radius: 50%;
  background: rgba(120, 40, 60, 0.85);
  color: #ffe8f0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.attack-btn:active,
.attack-btn.is-down {
  background: #c4557a;
}

.user-name {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: 60%;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 26, 43, 0.82);
  border: 1px solid #3d4a66;
  color: #cfe0ff;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.finish-btn {
  position: absolute;
  left: 50%;
  bottom: 172px;
  transform: translateX(-50%);
  padding: 12px 24px;
  border: 1px solid #ffd166;
  border-radius: 999px;
  background: #ffd166;
  color: #1a1f2b;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.finish-btn[hidden] { display: none; }

.finish-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

.finish-note {
  position: absolute;
  left: 50%;
  bottom: 216px;
  transform: translateX(-50%);
  max-width: 90%;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid #3d4a66;
  border-radius: 10px;
  background: rgba(16, 26, 43, 0.9);
  color: #ffe08a;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

.finish-note:empty { display: none; }

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: #9aa6bd;
}

@media (max-height: 420px) {
  .pad { bottom: 34px; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); }
  .hint { display: none; }
  .finish-btn { bottom: 140px; padding: 10px 18px; font-size: 15px; }
  .finish-note { bottom: 184px; font-size: 12px; }
  .attack-btn { bottom: 42px; width: 58px; height: 58px; font-size: 14px; }
}
