/* ===========================================================
   PIXEL PET — 레트로 휴대용 게임기 UI
   레이아웃: 케이스 > 베젤 > 액정(LCD) > 물리 버튼 3개
   =========================================================== */

:root {
  --case: #d9576b;
  --case-dark: #b13c50;
  --case-light: #f08a99;
  --bezel: #2a2333;
  --lcd: #b7d3a0;
  --lcd-dark: #96b681;
  --ink: #23301f;
  --ink-soft: #4a5c43;
  --good: #3f7a3a;
  --warn: #a67c1f;
  --bad: #a8362f;
  --font: 'DungGeunMo', 'Galmuri11', ui-monospace, 'Apple SD Gothic Neo', 'Malgun Gothic', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 12px 40px;
  background: radial-gradient(circle at 50% 0%, #2e2740 0%, #16121f 70%);
  color: #e8e4f2;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 게임기 케이스 ---------- */

.device {
  width: min(340px, 100%);
  padding: 16px 16px 14px;
  border-radius: 46px 46px 60px 60px / 40px 40px 90px 90px;
  background: linear-gradient(160deg, var(--case-light) 0%, var(--case) 38%, var(--case-dark) 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -6px 12px rgba(0, 0, 0, 0.28),
    0 18px 36px rgba(0, 0, 0, 0.45);
}

.device__top,
.device__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.device__top {
  padding: 2px 8px 10px;
}

.device__brand {
  font-weight: 700;
  letter-spacing: 0.22em;
}

.device__bottom {
  padding: 10px 8px 0;
  font-size: 10px;
}

.linkbtn {
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 10px;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px;
}

.linkbtn:hover {
  color: #fff;
}

/* ---------- 베젤 + 액정 ---------- */

.bezel {
  padding: 12px;
  border-radius: 26px;
  background: linear-gradient(180deg, #3a3049 0%, var(--bezel) 100%);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.6),
    0 2px 0 rgba(255, 255, 255, 0.25);
}

.lcd {
  position: relative;
  padding: 8px 9px 9px;
  border-radius: 6px;
  background: var(--lcd);
  color: var(--ink);
  /* LCD 격자 질감 */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 4px 4px, 4px 4px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(60, 90, 50, 0.5);
  transition: background-color 400ms;
}

.lcd[data-sleeping='true'] {
  background-color: #8fae86;
}

.lcd[data-phase='dead'] {
  background-color: #a8a99a;
}

.lcd__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  padding-bottom: 4px;
  border-bottom: 2px dotted rgba(35, 48, 31, 0.35);
}

.lcd__name {
  font-weight: 700;
  font-size: 13px;
}

.lcd__stage {
  color: var(--ink-soft);
}

.lcd__body {
  position: relative;
  margin: 6px 0;
}

.lcd__canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 128 / 96;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- 스탯 게이지 ---------- */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
  padding: 4px 0 6px;
  border-top: 2px dotted rgba(35, 48, 31, 0.35);
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
}

.stat__label {
  width: 34px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.stat__gauge {
  display: flex;
  gap: 1px;
  flex: 1;
}

.stat__gauge i {
  flex: 1;
  height: 7px;
  background: rgba(35, 48, 31, 0.14);
}

.stat[data-level='good'] .stat__gauge i.is-on {
  background: var(--good);
}
.stat[data-level='warn'] .stat__gauge i.is-on {
  background: var(--warn);
}
.stat[data-level='bad'] .stat__gauge i.is-on {
  background: var(--bad);
  animation: blink 900ms steps(2, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- 메시지 티커 ---------- */

.ticker {
  margin: 0 0 6px;
  min-height: 15px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.ticker[data-tone='good'] {
  color: var(--good);
}
.ticker[data-tone='warn'] {
  color: var(--warn);
}
.ticker[data-tone='bad'] {
  color: var(--bad);
  font-weight: 700;
}

/* ---------- 액정 안 메뉴 ---------- */

.menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.menu__item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 2px;
  border: 2px solid rgba(35, 48, 31, 0.3);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--ink);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.menu__cursor {
  visibility: hidden;
  font-size: 9px;
}

.menu__item.is-active {
  background: var(--ink);
  color: var(--lcd);
  border-color: var(--ink);
}

.menu__item.is-active .menu__cursor {
  visibility: visible;
}

.menu__item.is-blocked {
  opacity: 0.45;
}

/* ---------- 상태 패널 / 사망 오버레이 ---------- */

.panel,
.overlay {
  position: absolute;
  inset: 0;
  padding: 8px 10px;
  background: var(--lcd);
  box-shadow: inset 0 0 0 2px rgba(35, 48, 31, 0.45);
  overflow: auto;
  font-size: 10px;
  line-height: 1.5;
}

.panel__title {
  margin: 0 0 4px;
  font-size: 11px;
  border-bottom: 2px dotted rgba(35, 48, 31, 0.4);
  padding-bottom: 3px;
}

.panel__list {
  margin: 0;
}

.panel__list > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.panel__list dt {
  color: var(--ink-soft);
}

.panel__list dd {
  margin: 0;
  text-align: right;
}

.panel__chain {
  margin: 5px 0 0;
  color: var(--ink-soft);
  word-break: keep-all;
}

.panel__hint {
  margin: 6px 0 0;
  text-align: right;
  color: var(--ink-soft);
}

.overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  background: #a8a99a;
}

.overlay h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.overlay p {
  margin: 0;
}

.overlay__score {
  font-weight: 700;
}

.overlay__hint {
  margin-top: 6px !important;
  color: #3f4436;
  animation: blink 1400ms steps(2, end) infinite;
}

/* ---------- 물리 버튼 ---------- */

.pad {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 22px;
  padding: 18px 0 4px;
}

.pad__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 58px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.pad__key {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #4a1520;
  background: linear-gradient(165deg, #fff1f3 0%, #e6b9c1 55%, #c78d98 100%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.9),
    inset 0 -3px 4px rgba(0, 0, 0, 0.25),
    0 4px 0 var(--case-dark),
    0 6px 8px rgba(0, 0, 0, 0.35);
  transition: transform 60ms, box-shadow 60ms;
}

.pad__btn--mid .pad__key {
  width: 48px;
  height: 48px;
}

.pad__btn:active .pad__key {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.3),
    0 0 0 var(--case-dark),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.pad__label {
  letter-spacing: 0.06em;
}

/* ---------- 하단 안내 ---------- */

.hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: rgba(232, 228, 242, 0.6);
}

@media (max-width: 380px) {
  .device {
    width: 100%;
  }
  .pad {
    gap: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat[data-level='bad'] .stat__gauge i.is-on,
  .overlay__hint {
    animation: none;
  }
}

/* ---------- 통합 로그인 다이얼로그 ---------- */

.device__bottomBtns {
  display: flex;
  gap: 10px;
}

.account {
  border: 3px solid var(--bezel);
  border-radius: 12px;
  background: var(--lcd);
  color: var(--ink);
  font-family: var(--font);
  padding: 18px 20px;
  max-width: min(320px, calc(100vw - 32px));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.account::backdrop {
  background: rgba(10, 8, 16, 0.65);
}

.account__title {
  margin: 0 0 6px;
  font-size: 16px;
}

.account__desc {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.account__field {
  display: block;
  font-size: 12px;
  margin-bottom: 10px;
}

.account__field input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border: 2px solid var(--ink-soft);
  border-radius: 6px;
  background: #f4f9ec;
  color: var(--ink);
  font: inherit;
}

.account__field input:focus {
  outline: 2px solid var(--case);
  outline-offset: 1px;
}

.account__error {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--bad);
}

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

.account__actions button {
  flex: 1;
  padding: 8px 0;
  border: 2px solid var(--bezel);
  border-radius: 8px;
  background: var(--case);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.account__actions .account__signup {
  background: var(--lcd-dark);
  color: var(--ink);
}

.account__actions #accountCancel {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--ink-soft);
}

.account__actions button:hover {
  filter: brightness(1.08);
}
