* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f5f5f5;
  --white: #ffffff;
  --black: #111111;
  --gray: #888888;
  --light-gray: #e8e8e8;
  --accent: #111111;
  --success: #2d9e5c;
  --danger: #d94f4f;
  --border: #dddddd;
  --font-main: 'Noto Sans JP', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

body {
  background: var(--bg);
  font-family: var(--font-main);
  height: 100dvh;
  overflow: hidden;
  color: var(--black);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
}

/* HEADER */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

#shop-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
}

#stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

#day-display {
  font-size: 12px;
  color: var(--gray);
  font-family: var(--font-mono);
}

#money-display {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}

/* MAIN */
#main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* CUSTOMER AREA */
#customer-area {
  flex: 0 0 auto;
  min-height: 180px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#customer-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  animation: slideIn 0.3s ease;
}

#customer-card.hidden { display: none; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

#customer-avatar {
  font-size: 48px;
  flex-shrink: 0;
  line-height: 1;
}

#customer-info-col {
  flex: 1;
}

#customer-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

#customer-type-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--gray);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

#speech-bubble {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-top-left-radius: 2px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  min-height: 60px;
  position: relative;
}

#speech-text {
  color: var(--black);
}

#speech-text.typing::after {
  content: '▋';
  animation: blink 0.8s infinite;
}

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

#no-customer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.waiting-text {
  color: var(--gray);
  font-size: 13px;
}

#next-customer-btn {
  padding: 10px 24px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
  display: none;
}

/* SHOP AREA */
#shop-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

#inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13px;
}

#restock-btn {
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-main);
}

#restock-btn:active {
  background: var(--light-gray);
}

#auto-sell-toggle {
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

#auto-sell-toggle.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

#auto-mode-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--black);
  color: var(--white);
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 1px;
  animation: pulse 1.2s infinite;
}

#auto-mode-badge.hidden { display: none; }

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

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--white);
  transition: border-color 0.15s;
  position: relative;
}

.item-card:active {
  background: var(--bg);
}

.item-card.selected {
  border-color: var(--black);
  border-width: 2px;
}

.item-card.out-of-stock {
  opacity: 0.4;
  cursor: not-allowed;
}

.item-emoji {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.item-name {
  font-size: 11px;
  color: var(--gray);
  margin-bottom: 2px;
}

.item-price {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.item-category {
  font-size: 10px;
  color: var(--gray);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1px 5px;
  display: inline-block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
}

.item-stock {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  color: var(--gray);
  font-family: var(--font-mono);
}

/* SELL PANEL */
#sell-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  animation: slideUp 0.25s ease;
  z-index: 10;
}

#sell-panel.hidden { display: none; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

#sell-panel-content { }

#sell-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

#sell-item-icon { font-size: 24px; }
#sell-item-name { flex: 1; }
#sell-item-cost {
  font-size: 11px;
  color: var(--gray);
  font-family: var(--font-mono);
}

#price-setter {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
}

.price-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  font-size: 22px;
  cursor: pointer;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
}

.price-btn:active { background: var(--light-gray); }

#price-display {
  text-align: center;
  min-width: 120px;
}

#price-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
}

#price-label {
  font-size: 11px;
  color: var(--gray);
}

#profit-preview {
  text-align: center;
  font-size: 12px;
  color: var(--gray);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

#profit-preview span {
  color: var(--success);
  font-weight: 700;
}

#sell-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
}

#cancel-sell-btn {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
}

#confirm-sell-btn {
  padding: 12px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#confirm-sell-btn:active { opacity: 0.8; }

/* TRANSACTION LOG */
#log-area {
  flex: 0 0 auto;
  max-height: 90px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#log-list {
  display: flex;
  flex-direction: column-reverse;
  padding: 6px 12px;
  gap: 4px;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 6px;
  border-radius: 6px;
  animation: logSlide 0.2s ease;
}

@keyframes logSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-entry.success {
  background: #edf7f1;
  color: var(--success);
}

.log-entry.failure {
  background: #fdf0f0;
  color: var(--danger);
}

.log-entry .log-icon { font-size: 13px; }
.log-entry .log-text { flex: 1; }
.log-entry .log-price { font-weight: 700; }

/* DAY END OVERLAY */
#day-end-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}

#day-end-overlay.hidden { display: none; }

#day-end-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  width: 300px;
  animation: popIn 0.3s ease;
}

#day-end-title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

#day-end-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.stat-row.total {
  font-weight: 700;
  font-size: 16px;
  border-bottom: none;
}

#next-day-btn {
  width: 100%;
  padding: 14px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}