*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black: #111;
  --white: #fff;
  --gray-100: #f5f5f5;
  --gray-200: #e8e8e8;
  --gray-400: #aaa;
  --gray-600: #666;
  --accent: #e63946;
  --accent-soft: #ffeaeb;
  --font-main: 'Noto Sans JP', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  background: var(--white);
  color: var(--black);
  font-family: var(--font-main);
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- SETUP SCREEN ---- */
.setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px 24px;
  gap: 0;
}

.setup-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.setup-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.setup-subtitle {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 36px;
}

.setup-card {
  width: 100%;
  max-width: 360px;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.setup-card h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-600);
  margin-bottom: 16px;
}

.time-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.time-btn {
  border: 2px solid transparent;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  color: var(--black);
}

.time-btn:active { transform: scale(0.96); }

.time-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.pax-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pax-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  background: var(--white);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--black);
}

.pax-btn:active { transform: scale(0.9); }

.pax-count {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  min-width: 60px;
  text-align: center;
}

.pax-label {
  font-size: 13px;
  color: var(--gray-600);
  text-align: center;
}

.start-btn {
  width: 100%;
  max-width: 360px;
  padding: 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--black);
  color: var(--white);
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.start-btn:active { transform: scale(0.97); }

/* ---- MAIN SCREEN ---- */
.main-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.timer-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.timer-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-600);
}

.timer-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--black);
  transition: color 0.3s;
}

.timer-value.warning { color: var(--accent); }

.timer-bar-wrap {
  width: 100px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: var(--black);
  border-radius: 2px;
  transition: width 1s linear, background 0.3s;
}

.timer-bar.warning { background: var(--accent); }

.cart-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--black);
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.cart-btn:active { transform: scale(0.92); }

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  border-bottom: 1px solid var(--gray-200);
}

.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-600);
  font-family: var(--font-main);
}

.cat-tab.active {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* Menu Grid */
.menu-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
  scrollbar-width: none;
}

.menu-scroll::-webkit-scrollbar { display: none; }

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

.menu-item {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.menu-item:active { transform: scale(0.97); }

.menu-item.in-cart {
  border-color: var(--black);
  background: var(--white);
}

.item-emoji { font-size: 30px; line-height: 1; }

.item-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.item-desc {
  font-size: 11px;
  color: var(--gray-600);
  line-height: 1.4;
}

.item-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--black);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-add-btn {
  margin-top: 4px;
  padding: 7px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--black);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
  transition: all 0.15s;
}

/* Cart Sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  z-index: 101;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 14px auto 0;
  flex-shrink: 0;
}

.sheet-header {
  padding: 14px 20px 12px;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  border-bottom: 1px solid var(--gray-200);
}

.sheet-body {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
}

.sheet-body::-webkit-scrollbar { display: none; }

.cart-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}

.cart-empty .empty-icon { font-size: 40px; margin-bottom: 12px; }

.cart-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.cart-item-emoji { font-size: 24px; flex-shrink: 0; }

.cart-item-info { flex: 1; }

.cart-item-name { font-size: 14px; font-weight: 700; }
.cart-item-sub { font-size: 12px; color: var(--gray-600); margin-top: 2px; }

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--black);
  font-weight: 700;
  line-height: 1;
  transition: all 0.12s;
}

.qty-btn:active { transform: scale(0.88); }

.qty-num {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.sheet-footer {
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.order-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.order-btn:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
}

.order-btn:not(:disabled):active { transform: scale(0.97); }

/* Orders History */
.orders-section {
  padding: 0 20px 20px;
}

.orders-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-600);
  padding: 14px 0 8px;
}

.order-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
}

.order-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
  margin-right: 8px;
}

.order-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-600);
}

.order-status.serving {
  background: #e8f5e9;
  color: #2e7d32;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--black);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Ended Screen */
.ended-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px 24px;
  gap: 16px;
  text-align: center;
}

.ended-icon { font-size: 64px; }
.ended-title { font-size: 26px; font-weight: 700; }
.ended-sub { font-size: 14px; color: var(--gray-600); line-height: 1.6; }

.stats-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.stat-box {
  flex: 1;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}

.stat-label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

.restart-btn {
  width: 100%;
  max-width: 320px;
  padding: 16px;
  border: 2px solid var(--black);
  border-radius: var(--radius);
  background: transparent;
  color: var(--black);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
  transition: all 0.15s;
}

.restart-btn:active { transform: scale(0.97); }

/* Warning pulse */
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-value.warning { animation: pulse-red 1s infinite; }