/* ============================================================
   おかいものごっこ PWA
   色は Android 版 ui/theme/Color.kt の値をそのまま流用
   ============================================================ */
:root {
  --creamy-orange: #FFF3E0;
  --dark-orange:   #E65100;
  --forest-green:  #4CAF50;
  --sky-blue:      #2196F3;
  --rose-pink:     #E91E63;
  --light-yellow:  #FFF9C4;
  --gray:          #888888;
  --brand-green:   #327259;  /* アイコンの深緑 */
  --brand-peach:   #FCB382;  /* アイコンのペールオレンジ */

  --text:      #1C1B1F;
  --text-weak: #6B6B70;
  --surface:   #FFFFFF;
  --shadow:    0 4px 12px rgba(0, 0, 0, .18);
  --radius:    20px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

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

/* button { display: inline-flex } が UA の [hidden] を上書きしてしまうため */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN",
               "Yu Gothic UI", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  user-select: none;
}

#app { height: 100%; }

.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- 共通ボタン ---------- */
button {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  color: #fff;
  background: var(--sky-blue);
  cursor: pointer;
  transition: transform .08s ease, filter .12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
}
button:active:not(:disabled) { transform: scale(.97); filter: brightness(.94); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid var(--dark-orange); outline-offset: 2px; }

.btn-text {
  background: none;
  color: var(--text-weak);
  font-size: 1.1rem;
  padding: .7em 1em;
}

/* ---------- ホーム ---------- */
.home {
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  gap: 12px;
  justify-content: space-around;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.balance-card {
  background: var(--creamy-orange);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
}
.balance-card .label { font-size: 1.35rem; color: var(--gray); }
.balance-card .value {
  font-size: clamp(2.4rem, 13vw, 3.4rem);
  font-weight: 800;
  color: var(--dark-orange);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.charge-btn {
  background: var(--forest-green);
  height: 62px;
  width: 80%;
  margin: 0 auto;
  font-size: 1.25rem;
  flex: 0 0 auto;
}

.divider { height: 1px; background: #E0E0E0; margin: 4px 0; flex: 0 0 auto; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 0 0 auto;
}
.mode-btn {
  height: 112px;
  border-radius: 16px;
  flex-direction: column;
  gap: 6px;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
}
.mode-btn .emoji { font-size: 2.1rem; line-height: 1; }
.mode-btn.clerk    { background: var(--sky-blue); }
.mode-btn.customer { background: var(--rose-pink); }
.mode-btn.sales    { background: var(--light-yellow); color: #5D4037; }
.mode-btn.settings { background: var(--gray); }

.install-btn {
  background: var(--dark-orange);
  height: 46px;
  font-size: .95rem;
  align-self: center;
  padding: 0 1.2em;
  flex: 0 0 auto;
}

/* ---------- カメラ画面 ---------- */
.camera-wrap { position: relative; flex: 1 1 auto; overflow: hidden; background: #000; }
.camera-wrap video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.reticle {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 4px solid var(--rose-pink);
  border-radius: 16px;
  pointer-events: none;
}
.reticle.barcode { width: min(300px, 84vw); height: 150px; border-color: #F44336; }
.reticle.qr      { width: min(250px, 70vw); aspect-ratio: 1; border-color: #2962FF; }

.overlay-back {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  background: rgba(0, 0, 0, .55);
  height: 44px; padding: 0 1.1em;
  font-size: 1rem;
}
.overlay-back.bottom {
  top: auto;
  bottom: calc(12px + var(--safe-bottom));
}
.overlay-hint {
  position: absolute;
  top: calc(48px + var(--safe-top));
  left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .8);
  white-space: pre-line;
  pointer-events: none;
}
.camera-error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
  color: #fff; text-align: center; font-size: 1.15rem; line-height: 1.6;
}

/* ---------- てんいんさん 下部パネル ---------- */
.info-panel {
  background: rgba(255, 255, 255, .96);
  border-radius: 24px 24px 0 0;
  margin-top: -24px;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  flex: 0 0 auto;
  z-index: 2;
}
.seg { display: flex; width: 100%; }
.seg button {
  flex: 1; height: 46px; border-radius: 0;
  background: #fff; color: var(--sky-blue);
  box-shadow: inset 0 0 0 2px var(--sky-blue);
  font-size: 1rem;
}
.seg button:first-child { border-radius: 16px 0 0 16px; }
.seg button:last-child  { border-radius: 0 16px 16px 0; }
.seg button[aria-pressed="true"] { background: var(--sky-blue); color: #fff; }

.scan-name  { font-size: 1.5rem; font-weight: 800; text-align: center; }
.scan-name.unregistered { color: #D32F2F; }
.scan-price { font-size: 2.5rem; font-weight: 800; color: #1565C0; }
.scan-idle  { font-size: 1.25rem; color: var(--gray); }
.scan-total { font-size: 2rem; font-weight: 800; color: #D81B60; }
.pay-btn    { background: var(--forest-green); height: 62px; width: 100%; font-size: 1.4rem; }

.reg-box {
  min-height: 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.reg-box .code { font-size: 1.5rem; font-weight: 800; color: #000; word-break: break-all; }
.reg-box .cap  { font-size: 1rem; color: var(--gray); }
.reg-box .msg  { font-size: 1.1rem; }

/* ---------- おしはらい / 支払い ---------- */
.pay-screen {
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  align-items: center; justify-content: space-evenly; text-align: center;
  background: #fff; gap: 8px;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.pay-screen.compact { justify-content: center; gap: 18px; }
.pay-title  { font-size: 2rem; font-weight: 800; color: var(--rose-pink); margin: 0; }
.pay-amount { font-size: clamp(2.6rem, 15vw, 3.75rem); font-weight: 800; margin: 0;
              font-variant-numeric: tabular-nums; }
.pay-sub    { font-size: 1.15rem; color: var(--gray); margin: 0; }
.pay-wallet { font-size: 1.25rem; margin: 0; }
.qr-box {
  width: min(300px, 74vw); aspect-ratio: 1;
  background: #fff; padding: 8px;
  border-radius: 12px; box-shadow: var(--shadow);
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.finish-btn { background: var(--sky-blue); height: 78px; width: 100%; font-size: 1.4rem; }
.do-pay-btn { background: var(--rose-pink); height: 80px; width: 100%; font-size: 1.9rem;
              border-radius: 16px; }

.shortage-card {
  background: #FFEBEE; border-radius: 16px; padding: 16px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.shortage-card .emoji { font-size: 2.6rem; line-height: 1; }
.shortage-card .msg   { font-size: 1.4rem; font-weight: 800; color: #D32F2F; }
.autocharge-btn { background: #FF9800; height: 60px; width: 100%; font-size: 1.25rem; }

/* ---------- トップバー付き画面 ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--creamy-orange);
  flex: 0 0 auto;
}
.topbar h1 { font-size: 1.35rem; margin: 0; font-weight: 800; }
.icon-btn {
  background: none; color: var(--text);
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 1.5rem; flex: 0 0 auto;
}
.page {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  max-width: 560px; margin: 0 auto; width: 100%;
}

.total-card {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  padding: 16px; text-align: center; margin-bottom: 8px;
}
.total-card .label { font-size: 1.2rem; color: var(--gray); }
.total-card .value { font-size: 2.4rem; font-weight: 800; color: #1565C0; }

.sale-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 2px; border-bottom: 1px solid #E0E0E0;
}
.sale-row .when { font-size: 1rem; color: #444; }
.sale-row .amt  { font-size: 1.25rem; font-weight: 600; }
.empty { text-align: center; color: var(--gray); font-size: 1.1rem; padding: 48px 0; }

/* ---------- せってい ---------- */
.setting-list { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.setting-list h2 { font-size: 1.25rem; margin: 0; text-align: center; }
.rec-btn  { background: var(--sky-blue); height: 80px; width: 100%; font-size: 1.35rem; }
.rec-btn.recording { background: #D32F2F; }
.play-btn { background: var(--forest-green); height: 56px; width: 100%; font-size: 1.15rem; }
.warn { color: #D32F2F; font-size: 1.1rem; text-align: center; }
.note { color: var(--text-weak); font-size: .95rem; line-height: 1.7; text-align: center; }

/* ---------- ダイアログ ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.dialog {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  padding: 24px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}
.dialog h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px; text-align: center; }
.dialog button:not(.btn-text) { height: 52px; font-size: 1.15rem; }
.dialog label { font-size: .95rem; color: var(--text-weak); }
.dialog input {
  font-family: inherit; font-size: 1.25rem; width: 100%;
  padding: .55em .6em; border: 2px solid #BDBDBD; border-radius: 10px;
  color: var(--text); background: #fff; user-select: text;
}
.dialog input:focus { outline: none; border-color: var(--sky-blue); }
.dialog .row { display: flex; gap: 8px; }
.dialog .row button { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .82); color: #fff;
  padding: .7em 1.2em; border-radius: 999px; font-size: 1rem;
  z-index: 200; max-width: 88vw; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled) { transform: none; }
}
