:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: #162334;
  background: #fbf8f1;
  --navy: #0b263d;
  --navy-2: #123552;
  --gold: #c79a43;
  --gold-2: #e8c06d;
  --gold-soft: #f7edda;
  --paper: #fffdf8;
  --paper-2: #fbf6ed;
  --line: #eadfcd;
  --line-strong: #dac8ad;
  --muted: #6d7480;
  --green: #188253;
  --amber: #b46b18;
  --amber-soft: #fff4d8;
  --red: #b42318;
  --red-soft: #fff0ed;
  --gray-soft: #f1f3f5;
  --blue-soft: #eaf3ff;
  --shadow: 0 6px 18px rgba(22, 35, 52, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #fbf8f1;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  color: #132236;
  background: var(--gold-2);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button svg,
.brand-icon,
.section-icon,
.choice-icon,
.button-icon,
.note-icon,
.result-icon svg {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-icon {
  width: 18px;
  height: 18px;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 8px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

#store-view.panel {
  display: grid;
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  color: var(--navy);
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.15;
}

h2 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
  line-height: 1.35;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--navy);
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid #d1d7dd;
  border-radius: 8px;
  padding: 10px 12px;
  color: #1f2937;
  background: #ffffff;
}

input::placeholder {
  color: #98a1ad;
}

input:focus {
  outline: 3px solid rgba(199, 154, 67, 0.24);
  border-color: var(--gold);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

#login-view {
  width: min(460px, 100%);
  margin: 8dvh auto 0;
}

#login-view button {
  color: #ffffff;
  background: var(--navy);
}

.store-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  min-height: 72px;
  border-radius: 8px;
  padding: 12px 16px;
  color: #ffffff;
  background: var(--navy);
  box-shadow: var(--shadow);
}

.store-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0 auto;
  width: 42%;
  height: 100%;
  border-top-left-radius: 120px;
  background:
    repeating-radial-gradient(circle at 100% 100%, transparent 0 14px, rgba(199, 154, 67, 0.22) 15px 16px);
  opacity: 0.65;
  pointer-events: none;
}

.store-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  color: var(--gold-2);
  stroke-width: 1.8;
}

.store-header h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 900;
}

.store-header span {
  display: inline-block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 700;
}

.store-header button {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--gold-2);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.ui-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.section-header {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.section-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.section-header.centered {
  margin: 0;
  text-align: center;
}

.section-icon {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 50%;
  color: var(--gold);
  background: var(--gold-soft);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.mode-switch button {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 82px;
  border: 1px solid #e1e5ea;
  color: var(--navy);
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(22, 35, 52, 0.06);
  text-align: left;
}

.mode-switch button:hover {
  border-color: var(--gold);
}

.mode-switch .mode-active {
  border-color: var(--gold);
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 8px 20px rgba(11, 38, 61, 0.18);
}

.choice-icon {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 50%;
  color: var(--navy);
  background: #f3efe7;
}

.mode-active .choice-icon {
  color: var(--gold-2);
  background: rgba(255, 255, 255, 0.1);
}

.choice-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.choice-copy strong {
  font-size: 18px;
  line-height: 1.25;
}

.choice-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.mode-active .choice-copy small {
  color: rgba(255, 255, 255, 0.76);
}

.choice-check {
  position: absolute;
  top: -8px;
  right: -8px;
  display: none;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--gold);
  box-shadow: 0 4px 12px rgba(199, 154, 67, 0.32);
}

.choice-check svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-active .choice-check {
  display: grid;
}

.operation-section,
.result-section {
  display: grid;
}

.operation-section {
  align-content: start;
}

.operation-placeholder {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--paper-2);
}

.operation-panel {
  --action-width: min(100%, 380px);
  display: grid;
  gap: 10px;
  align-content: start;
}

.scanner-area {
  gap: 10px;
}

.camera-control {
  --camera-width: var(--action-width);
  display: grid;
  justify-items: center;
  gap: 9px;
}

.camera-frame {
  position: relative;
  width: var(--camera-width);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #162334;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.camera-frame::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 6px;
  background:
    linear-gradient(#ffffff, #ffffff) left top / 28px 3px no-repeat,
    linear-gradient(#ffffff, #ffffff) left top / 3px 28px no-repeat,
    linear-gradient(#ffffff, #ffffff) right top / 28px 3px no-repeat,
    linear-gradient(#ffffff, #ffffff) right top / 3px 28px no-repeat,
    linear-gradient(#ffffff, #ffffff) left bottom / 28px 3px no-repeat,
    linear-gradient(#ffffff, #ffffff) left bottom / 3px 28px no-repeat,
    linear-gradient(#ffffff, #ffffff) right bottom / 28px 3px no-repeat,
    linear-gradient(#ffffff, #ffffff) right bottom / 3px 28px no-repeat;
  opacity: 0.9;
  pointer-events: none;
}

#camera-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-control button,
.manual-form button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: var(--camera-width);
  max-width: 100%;
  height: 40px;
  min-height: 40px;
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 3px 0 var(--gold);
  line-height: 1;
  white-space: nowrap;
}

.support-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  border-radius: 8px;
  padding: 9px 11px;
  color: #4d5663;
  background: var(--paper-2);
  font-size: 12px;
  line-height: 1.45;
}

.note-icon {
  width: 18px;
  height: 18px;
  color: var(--gold);
}

.scan-status {
  min-height: 16px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.manual-form {
  width: var(--action-width);
  margin: 0 auto;
  align-content: start;
}

.manual-form button {
  width: 100%;
}

.debug-readout {
  border: 1px solid #d1d7dd;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafb;
}

.debug-readout.hidden {
  display: none;
}

.debug-readout-header {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.debug-readout code {
  display: block;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.result-section {
  grid-template-rows: auto 1fr;
}

.result {
  display: grid;
  gap: 8px;
  min-height: 220px;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  background: var(--paper-2);
  text-align: center;
}

.result p {
  margin: 0;
}

.result-icon {
  display: none;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: #f2eadc;
}

.result-icon svg {
  width: 32px;
  height: 32px;
}

.result-empty .result-icon-empty,
.result-active .result-icon-active,
.result-redeemed .result-icon-redeemed,
.result-void .result-icon-void,
.result-not-found .result-icon-not-found,
.result-success .result-icon-success {
  display: grid;
}

#result-title {
  color: var(--navy);
  font-size: clamp(22px, 2.8vw, 28px);
  line-height: 1.18;
  font-weight: 900;
}

#result-detail {
  min-height: 18px;
  color: #4d5663;
  font-size: 15px;
  font-weight: 800;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  justify-content: center;
  gap: 7px;
  width: 100%;
  max-width: 380px;
  margin-top: 4px;
}

.result-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  font-size: 14px;
  white-space: nowrap;
}

#redeem-button {
  color: #ffffff;
  background: var(--navy);
  box-shadow: inset 0 -3px 0 var(--gold);
}

#close-result-button {
  border: 1px solid #d1d7dd;
  color: var(--navy);
  background: #ffffff;
}

.result-empty {
  color: var(--navy);
}

.result-empty .result-icon {
  width: 50px;
  height: 50px;
}

.result-empty .result-icon svg {
  width: 28px;
  height: 28px;
}

.result-empty #result-title {
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 800;
}

.result-empty #result-detail {
  font-weight: 700;
}

.result-active {
  border-style: solid;
  border-color: var(--gold);
  background: var(--paper);
}

.result-active .result-icon {
  color: #ffffff;
  background: var(--green);
}

.result-active #result-title {
  color: var(--green);
}

.result-redeemed {
  border-style: solid;
  border-color: #efcf74;
  background: var(--amber-soft);
}

.result-redeemed .result-icon {
  color: #ffffff;
  background: var(--amber);
}

.result-redeemed #result-title {
  color: var(--amber);
}

.result-void {
  border-style: solid;
  border-color: #f0aaa1;
  background: var(--red-soft);
}

.result-void .result-icon {
  color: #ffffff;
  background: var(--red);
}

.result-void #result-title {
  color: var(--red);
}

.result-not-found {
  border-style: solid;
  border-color: #d0d5dd;
  background: var(--gray-soft);
}

.result-not-found .result-icon {
  color: #ffffff;
  background: #727b86;
}

.result-success {
  border-style: solid;
  border-color: #9ec6eb;
  background: var(--blue-soft);
}

.result-success .result-icon {
  color: #ffffff;
  background: var(--navy-2);
}

.operation-panel form {
  gap: 12px;
}

@media (orientation: landscape) and (min-width: 760px) {
  .app-shell {
    width: min(1240px, 100%);
    padding: 6px 10px;
  }

  #store-view.panel {
    grid-template-columns: minmax(0, 1fr) minmax(310px, 0.88fr);
    grid-template-areas:
      "header header"
      "method method"
      "operation result";
    gap: 8px;
  }

  .store-header {
    grid-area: header;
    min-height: 58px;
    padding: 8px 14px;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
  }

  .store-header h1 {
    font-size: 24px;
  }

  .store-header span {
    margin-top: 1px;
    font-size: 12px;
  }

  .store-header button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
  }

  .method-section {
    grid-area: method;
  }

  .operation-section {
    grid-area: operation;
  }

  .result-section {
    grid-area: result;
  }

  .ui-section {
    padding: 9px;
  }

  .section-header {
    gap: 1px;
    margin-bottom: 6px;
  }

  .section-icon {
    width: 26px;
    height: 26px;
    padding: 6px;
  }

  h2 {
    font-size: 15px;
  }

  .section-header p {
    font-size: 11px;
    line-height: 1.25;
  }

  .mode-switch button {
    min-height: 58px;
    gap: 9px;
    padding: 7px 10px;
  }

  .choice-icon {
    width: 34px;
    height: 34px;
    padding: 8px;
  }

  .choice-copy strong {
    font-size: 15px;
  }

  .choice-copy small {
    font-size: 11px;
  }

  .operation-panel {
    --action-width: min(100%, 340px);
  }

  .camera-control {
    gap: 7px;
  }

  .camera-control button,
  .manual-form button {
    height: 36px;
    min-height: 36px;
    padding: 7px 12px;
    font-size: 14px;
  }

  .support-note {
    padding: 7px 9px;
    font-size: 11px;
    line-height: 1.3;
  }

  .note-icon {
    width: 16px;
    height: 16px;
  }

  .operation-panel,
  .scanner-area {
    gap: 7px;
  }

  input {
    padding: 8px 10px;
  }

  .scan-status {
    min-height: 12px;
    font-size: 11px;
  }

  .result {
    min-height: 100%;
    gap: 6px;
    padding: 10px;
  }

  .result-icon {
    width: 48px;
    height: 48px;
  }

  .result-icon svg {
    width: 28px;
    height: 28px;
  }

  #result-title {
    font-size: clamp(20px, 2.2vw, 24px);
  }

  #result-detail {
    min-height: 16px;
    font-size: 13px;
  }

  .result-actions {
    grid-template-columns: repeat(2, minmax(0, 150px));
    max-width: 310px;
    gap: 6px;
  }

  .result-actions button {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .button-icon {
    width: 16px;
    height: 16px;
  }

  .result-empty .result-icon {
    width: 42px;
    height: 42px;
  }

  .result-empty .result-icon svg {
    width: 24px;
    height: 24px;
  }

  .result-empty #result-title {
    font-size: 18px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 6px;
  }

  .store-header {
    align-items: flex-start;
    padding: 12px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .store-header h1 {
    font-size: 22px;
  }

  .store-header button {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .mode-switch {
    grid-template-columns: 1fr;
  }

  .mode-switch button {
    min-height: 76px;
  }

  .result-actions {
    grid-template-columns: minmax(0, 260px);
  }
}

@media (orientation: portrait) and (min-width: 621px) {
  .app-shell {
    padding: 8px;
  }

  #store-view.panel {
    gap: 10px;
  }

  .store-header {
    min-height: 66px;
    padding: 12px 16px;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
  }

  .store-header h1 {
    font-size: 26px;
  }

  .ui-section {
    padding: 11px;
  }

  .mode-switch button {
    min-height: 76px;
  }

  .operation-panel {
    --action-width: min(100%, 350px);
  }

  .result {
    min-height: 190px;
  }
}
