/* style.css 최종 정리본 */

:root {
  --body: #dfe6e9; --frame: #b2bec3; --bezel: #2d3436; --card: #ffeaa7; --card-b: #fdcb6e; --pill: #55efc4; --btn: #0984e3; --btn-shadow: #074f78; --muted: #636e72; --ok: #2ecc71; --danger: #e67e22; --done: #27ae60;
}

* { 
  box-sizing: border-box; 
}

body {
  margin: 0;
  background: var(--body);
  font-family: 'Press Start 2P', 'Galmuri11', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.console {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  max-height: 880px;
  padding: 8px;
  background: var(--frame);
  border-radius: 20px;
  box-shadow: 0 0 0 4px #636e72 inset;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- 화면 레이아웃 --- */
.screen {
  height: 210px;
  flex-shrink: 0;
  background: var(--bezel);
  border-radius: 12px;
  color: white;
  display: flex;
  flex-direction: column;
}

.controls-container {
  flex-grow: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list {
  flex-grow: 1;
  min-height: 0;
  background: var(--body); /* body와 같은 색으로 통일 */
  border-radius: 12px;
  padding: 6px;
  overflow-y: auto;
}

/* --- 전투화면 --- */
.hud {
  display: flex;
  gap: 6px;
  padding: 8px;
  font-size: 10px;
}

.hp {
  flex: 1;
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  height: 10px;
  margin-top: 4px;
}

.hp > i {
  display: block;
  height: 100%;
  width: 100%;
  background: #00e676;
  transition: width 0.4s ease;
}

.arena {
  flex: 1;
  display: flex;
  align-items: flex-end; /* 캐릭터를 arena 하단에 붙임 */
  justify-content: center;
  gap: 90px;
  position: relative;
  padding-bottom: 20px; /* 살짝 위로 띄운 효과 */
}

.vs {
  margin: 0 6px;
  font-size: 12px;
  opacity: 0.8;
}

/* === 캐릭터 스타일 (수정 안정판) === */
.character {
  width: 32px;
  height: 32px;
  position: relative;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
  transition: transform 0.6s ease, opacity 0.6s ease;
  will-change: transform;
}

/* 기본 idle 상태 */
.character.sprite {
  background-image: url('./smp_sp.png');
  background-size: 1024px 832px;
  background-repeat: no-repeat;
  background-position: 0 0;
  animation: idle 0.8s steps(2) infinite;
}

/* 기본 확대는 arena 안쪽에서 통일 */
.arena .character {
  transform: scale(3);
}

/* 좌우 반전만 추가 */
.character.left  { transform: scale(3) scaleX(-1); }
.character.right { transform: scale(3) scaleX(1); }

@keyframes idle {
  from { background-position-x: 0; }
  to   { background-position-x: -64px; }
}

/* 공격 애니메이션은 scale 고정 */
@keyframes attack-left {
  0% { transform: scale(3) scaleX(-1) translateX(0); }
  50% { transform: scale(3) scaleX(-1) translateX(20px); }
  100% { transform: scale(3) scaleX(-1) translateX(0); }
}
@keyframes attack-right {
  0% { transform: scale(3) scaleX(1) translateX(0); }
  50% { transform: scale(3) scaleX(1) translateX(-20px); }
  100% { transform: scale(3) scaleX(1) translateX(0); }
}
.character.left.attack { animation: attack-left 0.5s ease; }
.character.right.attack { animation: attack-right 0.5s ease; }

/* 패배 연출 */
.character.defeated {
  animation: none !important; /* idle 멈춤 */
  opacity: 0.45;
}
#charA.defeated {
  transform-origin: 70% 100%;
  transform: scale(3) rotate(-90deg) translateY(10px);
}
#charB.defeated {
  transform-origin: 30% 100%;
  transform: scale(3) rotate(90deg) translateY(10px);
}

/* arena가 쓰러진 캐릭터가 밖으로 튀어나오지 않게 */
.arena { overflow: hidden; }

/* --- 하단 컨트롤 --- */
.match { 
  background: var(--card); border: 2px solid var(--card-b); border-radius: 10px; padding: 6px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 11px; line-height: 1.25; 
}
.header { display: flex; align-items: center; justify-content: space-between; }
.leftRow, .rightRow { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; display: inline-flex; align-items: center; }
.OPEN { background: var(--ok); color: #fff; } 
.CLOSED { background: var(--danger); color: #fff; } 
.SETTLED { background: var(--done); color: #fff; }
.muted { color: var(--muted); }
.bet-container { display: flex; gap: 6px; }
.bet-box { flex: 1; background: #fff; border: 2px solid #ccc; border-radius: 8px; padding: 6px 8px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background-color 0.2s, border-color 0.2s; min-width: 0; }
.bet-box.active { background-color: #fe9137; border-color: #ff0d45; }
.tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
.pill { background: var(--pill); padding: 3px 6px; border-radius: 6px; user-select: none; transition: opacity 0.2s; font-variant-numeric: tabular-nums; }
.pill.disabled { opacity: 0.4; pointer-events: none; }
.controls { display: flex; gap: 6px; padding: 0 6px; }
.amounts { 
  display: flex; 
  gap: 6px; 
  flex-wrap: wrap;
  flex-grow: 1; /* <-- 이 줄 추가 */
}
.abtn { background: #ffe082; border: 2px solid #ffca28; border-radius: 8px; padding: 8px 10px; font-size: 11px; cursor: pointer; }
.abtn.active { outline: 2px solid #ff8f00; }

.btn { background: var(--btn); color: #fff; border: none; padding: 10px 12px; border-radius: 8px; font-size: 11px; cursor: pointer; box-shadow: 0 2px var(--btn-shadow); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { opacity: 0.55; filter: grayscale(0.1); cursor: not-allowed; box-shadow: none; }
#summary { font-size: 11px; opacity: .7; display: flex; align-items: center; }
.result { font-size: 10px; margin-left: 6px; }
.remain { font-size: 10px; color: var(--muted); min-width: 32px; text-align: right; }
.tname:lang(ko), .pill:lang(ko) { font-family: "Galmuri11", sans-serif; font-weight: 700; }

@keyframes attack-left {
  0% { transform: scale(-3,3) translateX(0); }
  50% { transform: scale(-3,3) translateX(20px); }
  100% { transform: scale(-3,3) translateX(0); }
}

@keyframes attack-right {
  0% { transform: scale(3,3) translateX(0); }
  50% { transform: scale(3,3) translateX(20px); }
  100% { transform: scale(3,3) translateX(0); }
}

.character.left.attack { animation: attack-left 0.5s ease; }
.character.right.attack { animation: attack-right 0.5s ease; }

@keyframes shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-3px, 3px); }
  100% { transform: translate(0, 0); }
}

.arena.shake {
  animation: shake 0.4s;
}

.damage-text {
  position: absolute;
  color: #ff0000;
  font-size: 8px;
  font-weight: bold;
  animation: floatUp 1s ease-out forwards;
  pointer-events: none;
  text-shadow: 1px 1px 2px #000000;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

