:root {
  --color-primary: #333333;
  --color-secondary: #d2232a;
  --color-text-on-dark: #f3f1ff;
  --color-text-on-light: #333333;
  --color-surface: #ffffff;
  --color-surface-muted: #fafafa;
  --color-page: #f4f4f5;
  --color-border: #e4e4e7;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 6%);
  --radius-card: 12px;
  --radius-control: 8px;
  --page-gutter: clamp(12px, 8vw - 16px, 96px);
  --page-gap-block: clamp(12px, 3vw, 32px);
  --page-max-width: 1920px;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
  background: var(--color-page);
  color: var(--color-text-on-light);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body:has(.image-viewer[open]) {
  overflow: hidden;
}

.app-header {
  padding: max(14px, env(safe-area-inset-top)) env(safe-area-inset-right) 14px env(safe-area-inset-left);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.app-title {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding-inline: var(--page-gutter);
  color: var(--color-secondary);
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.app-subtitle {
  display: block;
  padding-left: 5px;
  color: var(--color-primary);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: var(--page-gap-block) calc(var(--page-gutter) + env(safe-area-inset-right)) var(--page-gap-block) calc(var(--page-gutter) + env(safe-area-inset-left));
}

.app-footer {
  padding: 14px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  text-align: center;
}

.status-message {
  margin: 0;
  padding: 32px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.table-card {
  overflow: clip;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.shop-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.shop-table th,
.shop-table .shop-cell {
  padding: 14px 20px;
  text-align: left;
}

.shop-table th {
  background: var(--color-primary);
  color: var(--color-text-on-dark);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.shop-table .toggle-column {
  width: 96px;
  padding-inline: 8px;
  text-align: center;
  white-space: nowrap;
}

.shop-row {
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.shop-row:last-child {
  border-bottom: 0;
}

.shop-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.shop-row.is-open {
  background: var(--color-secondary);
  color: var(--color-text-on-dark);
}

.shop-row:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

.shop-row.is-open:focus-visible {
  outline-color: var(--color-text-on-dark);
}

.shop-row.is-open .shop-cell {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-secondary);
}

.toggle-icon {
  display: inline-block;
  font-size: 0.75rem;
  opacity: 0.65;
}

.shop-row.is-open .toggle-icon {
  opacity: 1;
  transform: rotate(90deg);
}

.detail-cell {
  padding: clamp(12px, 3vw, 20px);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.shop-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-around;
}

.detail-title {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.detail-wide {
  flex: 1 0 100%;
  min-width: 0;
}

.detail-notes {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detail-empty {
  width: 100%;
  margin: 0;
  text-align: center;
}

.qr-section {
  flex: 0 0 min(320px, calc(50% - 12px));
  min-width: 0;
}

.image-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  cursor: zoom-in;
  touch-action: manipulation;
}

.image-button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.image-button img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-section .image-button {
  padding: 8px;
}

.menu-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-around;
}

.menu-list .image-button {
  flex: 0 0 min(100%, clamp(420px, calc(50% - 8px), 720px));
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--color-secondary);
  color: var(--color-text-on-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  touch-action: manipulation;
}

.button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.qr-section .button {
  display: flex;
  width: 100%;
  margin-top: 10px;
}

.image-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border: 0;
  background: var(--color-primary);
}

.image-viewer .button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1;
}

.image-viewer .button:focus-visible {
  outline-color: var(--color-text-on-dark);
}

.image-viewer-stage {
  width: 100%;
  height: 100%;
}

.image-viewer-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.menu-list .image-button img {
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

@media (width < 560px) {
  .qr-section {
    flex-basis: 100%;
  }
}

@media (hover: hover) and (pointer: fine) {
  .shop-row:hover {
    background: var(--color-secondary);
    color: var(--color-text-on-dark);
  }
}
