:root {
  --color-bg: #ffffff;
  --color-text: #1f2937;
  --color-border: #d1d5db;
  --color-selected: #2563eb;
  --color-disabled: #9ca3af;
  --color-panel: #f9fafb;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--color-text);
  background: #f3f4f6;
  line-height: 1.5;
  font-size: 1rem;
}

.container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 0.75rem;
}

.panel,
.event-header {
  min-width: 0;
  background: var(--color-panel);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.event-header p {
  margin-bottom: 0;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.125rem 0.125rem 0.375rem;
  -webkit-overflow-scrolling: touch;
}

.tab {
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  min-height: 2.75rem;
  flex: 0 0 auto;
  font: inherit;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--color-selected);
  color: #fff;
  border-color: var(--color-selected);
}

.seat-map {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: 0.5rem;
}

.seat-map::before {
  content: "座席表は左右にスワイプできます";
  display: block;
  color: #4b5563;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.floor-layout {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  min-width: max-content;
  padding: 0.25rem 0.125rem;
}

.seat-grid {
  display: grid;
  gap: 0.2rem;
  align-items: center;
}

.main-floor-layout {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stage-label {
  min-height: 2rem;
  padding: 0.35rem 1rem;
  border: 2px solid var(--color-selected);
  border-radius: 0.35rem;
  background: #eef2ff;
  color: var(--color-selected);
  font-weight: 700;
  text-align: center;
}

.aisle {
  min-height: 2.75rem;
}

.balcony {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding-top: 2.35rem;
}

.balcony-title {
  min-height: 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.balcony-seats {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.balcony-aisle-start {
  margin-top: 0.75rem;
}

.row-label {
  font-size: 0.875rem;
  text-align: center;
  font-weight: 700;
}

.seat-cell {
  position: relative;
  width: 2.75rem;
  min-height: 2.75rem;
}

.seat-cell input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.seat-cell input[type="checkbox"]:focus-visible + .seat-label {
  outline: 3px solid var(--color-selected);
  outline-offset: 2px;
}

.seat-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.875rem;
  user-select: none;
}

.seat-cell input[type="checkbox"]:checked + .seat-label {
  background: var(--color-selected);
  color: #fff;
  border-color: var(--color-selected);
}

.seat-label.is-disabled {
  background: var(--color-disabled);
  color: #fff;
  cursor: not-allowed;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0.25) 4px,
    transparent 4px,
    transparent 8px
  );
}

.seat-label.is-missing {
  visibility: hidden;
  border: none;
  background: transparent;
}

#reservation-form {
  display: grid;
  gap: 0.625rem;
}

.selected-seats {
  overflow-wrap: anywhere;
}

#reservation-form input {
  min-height: 2.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  width: 100%;
  font: inherit;
}

#submit-button {
  margin-top: 0.5rem;
  border: none;
  border-radius: 6px;
  background: var(--color-selected);
  color: #fff;
  min-height: 2.875rem;
  padding: 0.75rem 1rem;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

#submit-button:disabled {
  opacity: 0.7;
  cursor: progress;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

#submit-button.is-loading .spinner {
  display: inline-block;
}

#status-message.error {
  color: #b91c1c;
}

#status-message.success {
  color: #065f46;
}

@media (min-width: 601px) {
  .container {
    max-width: 980px;
    padding: 1.5rem;
  }

  .panel,
  .event-header {
    border-radius: 8px;
  }

  .tabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .floor-layout {
    justify-content: center;
    gap: 0.75rem;
  }

  .seat-map::before {
    display: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.event-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.event-logo {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
  flex: 0 0 auto;
}

.event-title h1 {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .event-logo {
    width: 2.5rem;
    height: 2.5rem;
  }
}
