/* ═══════════════════════════════════════════════════
   CookieLP Shop — Undertale Style
   ═══════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #000;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  image-rendering: pixelated;
  overflow: hidden;
  cursor: none;
}

/* ── Back link ───────────────────────────────────── */
.back-to-main {
  position: fixed;
  top: 12px; left: 16px;
  z-index: 9999;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #555;
  text-decoration: none;
  transition: color 0.1s steps(1);
  cursor: none;
}
.back-to-main:hover { color: #fff; }

/* ── Screen container ────────────────────────────── */
.ut-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

/* ── Scene (top area — merchant sprite) ─────────── */
.ut-scene {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  background: #000;
}

.ut-scene-bg {
  position: absolute;
  inset: 0;
  /* Subtle pixel floor line */
  border-bottom: 3px solid #fff;
}

.ut-sprite {
  position: relative;
  z-index: 2;
  width: 192px;
  height: 192px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── UI area (bottom ~55%) ───────────────────────── */
.ut-ui {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 3px solid #fff;
}

/* ── Player panel ────────────────────────────────── */
.ut-player-panel {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 16px 6px;
  border-bottom: 3px solid #fff;
  background: #000;
  flex-wrap: wrap;
  gap: 8px;
}

.ut-player-name {
  font-size: 11px;
  color: #ff0;
  min-width: 110px;
}

.ut-hp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.ut-hp-label {
  font-size: 10px;
  color: #ff0;
}

.ut-lv-val {
  font-size: 10px;
  color: #fff;
}

.ut-hp-bar {
  width: 100px;
  height: 10px;
  background: #000;
  border: 2px solid #fff;
  position: relative;
  image-rendering: pixelated;
}

.ut-hp-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 100%;
  background: #ff0;
  transition: width 0s steps(20);
}

.ut-hp-nums {
  font-size: 9px;
  color: #fff;
}

.ut-gold-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ut-gold-icon {
  font-size: 12px;
  color: #ff0;
  font-weight: bold;
}

.ut-gold-val {
  font-size: 11px;
  color: #ff0;
}

/* ── Dialog area ─────────────────────────────────── */
.ut-dialog-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 10px 16px 12px;
  gap: 10px;
}

/* ── Dialog box ──────────────────────────────────── */
.ut-dialog-box {
  border: 3px solid #fff;
  background: #000;
  padding: 10px 14px;
  min-height: 72px;
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.ut-dialog-text {
  font-size: 11px;
  line-height: 1.9;
  color: #fff;
  white-space: pre-wrap;
}

.ut-dialog-arrow {
  position: absolute;
  bottom: 6px; right: 10px;
  font-size: 10px;
  color: #fff;
  animation: utBlink 0.6s steps(1, end) infinite;
  display: none;
}

@keyframes utBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Main menu ───────────────────────────────────── */
.ut-main-menu {
  display: flex;
  gap: 0;
  border: 3px solid #fff;
  background: #000;
}

.ut-menu-item {
  flex: 1;
  padding: 8px 10px;
  font-size: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  border-right: 3px solid #fff;
  cursor: none;
  user-select: none;
}
.ut-menu-item:last-child { border-right: none; }

/* ── Heart cursor ────────────────────────────────── */
.ut-heart {
  color: transparent;
  font-size: 11px;
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}
.ut-heart--active {
  color: #f00;
}

/* ── Buy screen ──────────────────────────────────── */
.ut-buy-screen {
  display: flex;
  flex: 1;
  padding: 10px 16px 12px;
  gap: 12px;
}

/* Items box */
.ut-items-box {
  border: 3px solid #fff;
  background: #000;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  flex-shrink: 0;
}

.ut-items-title {
  font-size: 9px;
  color: #aaa;
  text-align: center;
  padding: 0 12px 8px;
  border-bottom: 2px solid #333;
  margin-bottom: 6px;
  letter-spacing: 0.1em;
}

.ut-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  cursor: none;
  user-select: none;
  gap: 0;
  white-space: nowrap;
}

.ut-item--back {
  margin-top: 4px;
  border-top: 2px solid #333;
  padding-top: 8px;
  color: #aaa;
}

.ut-item-name {
  flex-shrink: 0;
}

.ut-item-dots {
  flex: 1;
  overflow: hidden;
  margin: 0 4px;
  color: #555;
  /* dot-leaders */
}
.ut-item-dots::after {
  content: '......................................';
  font-size: 11px;
  letter-spacing: 1px;
}

.ut-item-price {
  flex-shrink: 0;
  color: #ff0;
  font-size: 11px;
  min-width: 42px;
  text-align: right;
}

/* Item desc box */
.ut-item-desc-box {
  border: 3px solid #fff;
  background: #000;
  flex: 1;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ut-item-desc-text {
  font-size: 10px;
  line-height: 2;
  color: #fff;
  white-space: pre-wrap;
}

/* ── Confirm screen ──────────────────────────────── */
.ut-confirm-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.ut-confirm-box {
  border: 3px solid #fff;
  background: #000;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 320px;
  max-width: 90vw;
}

.ut-confirm-title {
  font-size: 14px;
  color: #ff0;
  text-align: center;
  border-bottom: 2px solid #fff;
  padding-bottom: 10px;
}

.ut-confirm-price {
  font-size: 11px;
  color: #ff0;
  text-align: center;
}

.ut-confirm-text {
  font-size: 9px;
  color: #ccc;
  line-height: 2;
  text-align: center;
  white-space: pre-wrap;
}

.ut-confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.ut-confirm-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: none;
  user-select: none;
}

/* ── Goto screen ─────────────────────────────────── */
.ut-goto-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.ut-goto-box {
  border: 3px solid #fff;
  background: #000;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 340px;
  max-width: 92vw;
  align-items: flex-start;
}

.ut-goto-text {
  font-size: 9px;
  color: #fff;
  line-height: 2.2;
  white-space: pre-wrap;
}

.ut-goto-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ff0;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid #ff0;
  padding: 8px 14px;
  margin-top: 4px;
  cursor: none;
}
.ut-goto-btn:hover { background: #ff0; color: #000; }

.ut-goto-back {
  font-size: 10px;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: none;
  user-select: none;
  margin-top: 4px;
}
.ut-goto-back:hover { color: #fff; }

/* ── Flash overlay ───────────────────────────────── */
.ut-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 300;
}

/* ── Hidden ──────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Fade in ─────────────────────────────────────── */
@keyframes utFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.ut-screen {
  animation: utFadeIn 0.4s steps(8, end) both;
}

/* ── Scanlines effect ────────────────────────────── */
.ut-screen::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9000;
}

/* ── Waiting / success ───────────────────────────── */
.ut-pay-waiting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.ut-pay-dots {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ffcd75;
  animation: payBlink 1.2s steps(1) infinite;
}
@keyframes payBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
.ut-pay-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #555;
  line-height: 1.8;
}

/* ── Touch devices: восстановить курсор ─────────── */
@media (hover: none) and (pointer: coarse) {
  body { cursor: auto; }
  .ut-menu-item,
  .ut-item,
  .ut-confirm-btn,
  .ut-goto-btn,
  .ut-goto-back,
  .back-to-main { cursor: pointer !important; }
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 11px; }

  .ut-sprite { width: 128px; height: 128px; }

  .ut-items-box { min-width: 160px; }

  .ut-item-dots::after { content: '...........'; }

  .ut-player-name { font-size: 9px; }

  .ut-buy-screen { flex-direction: column; }

  .ut-item-desc-box { min-height: 80px; }
}

@media (max-width: 400px) {
  .ut-sprite { width: 96px; height: 96px; }
  .ut-buy-screen { padding: 6px 8px 8px; gap: 8px; }
  .ut-items-box { min-width: 0; }
}
