*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --nyanko: #FF7043;
  --nyanko-dark: #BF360C;
  --nyanko-light: #FFCCBC;
  --rare: #FFB300;
  --rare-dark: #E65100;
  --rare-light: #FFF8E1;
  --bg: #FFF5EE;
  --surface: #FFFFFF;
  --text: #3E2723;
  --text-sub: #8D6E63;
  --border: #F5DDD6;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans',
               'Noto Sans JP', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== VIEWS ===== */

.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
}

#view-home.active {
  min-height: 100vh;
}

#view-detail.active {
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}

/* ===== HOME ===== */

.home-header {
  background: var(--nyanko);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-icon {
  font-size: 28px;
  line-height: 1;
}

.home-header h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.home-main {
  flex: 1;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.ticket-card {
  width: 100%;
  min-height: 90px;
  border: none;
  border-radius: 20px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--nyanko), var(--nyanko-dark));
  color: #fff;
  box-shadow: 0 5px 18px rgba(255, 112, 67, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-align: left;
  font-family: inherit;
}

.ticket-card.rare {
  background: linear-gradient(135deg, var(--rare), var(--rare-dark));
  box-shadow: 0 5px 18px rgba(255, 179, 0, 0.4);
}

.ticket-card:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  font-size: 34px;
  line-height: 1;
}

.card-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.card-total {
  font-size: 26px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.22);
  padding: 6px 18px;
  border-radius: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== DETAIL ===== */

.detail-header {
  flex-shrink: 0;
  background: var(--nyanko);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

#view-detail.rare-mode .detail-header {
  background: var(--rare);
}

.back-btn {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.22);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
  min-width: 74px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.back-btn:active {
  background: rgba(255, 255, 255, 0.4);
}

.detail-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.total-strip {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.total-label {
  font-size: 14px;
  color: var(--text-sub);
  font-weight: 500;
}

.total-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--nyanko);
  line-height: 1;
}

#view-detail.rare-mode .total-value {
  color: var(--rare-dark);
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 80px;
}

.list-col-header {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.06em;
}

/* ===== DRAG & DROP ===== */

.drag-handle {
  flex-shrink: 0;
  width: 22px;
  height: 36px;
  background: none;
  border: none;
  color: #D7C0BB;
  font-size: 16px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
  color: #A1887F;
}

.item-row.is-dragging {
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.drop-placeholder {
  border-radius: 10px;
  background: var(--nyanko-light);
  border: 2px dashed var(--nyanko);
  box-sizing: border-box;
}

#view-detail.rare-mode .drop-placeholder {
  background: var(--rare-light);
  border-color: var(--rare);
}

/* ===== ITEM ROW ===== */

#item-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-height: 48px;
}

.name-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  background: transparent;
  padding: 0 2px;
  text-overflow: ellipsis;
}

.name-input:focus {
  text-overflow: clip;
}

.name-input::placeholder {
  color: #C5AEA8;
}

.count-input {
  width: 54px;
  flex-shrink: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 4px 2px;
  height: 36px;
  background: #fff;
  -moz-appearance: textfield;
}

.count-input::placeholder {
  color: #C5AEA8;
  font-weight: 400;
}

.del-btn {
  flex-shrink: 0;
  width: 32px;
  height: 36px;
  background: none;
  border: none;
  color: #D7C0BB;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s;
}

.del-btn:active {
  color: #EF5350;
}

/* 無効ボタン */
.dis-btn {
  flex-shrink: 0;
  height: 36px;
  width: 32px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #C5AEA8;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s;
}

.dis-btn.is-disabled {
  color: var(--nyanko);
}

#view-detail.rare-mode .dis-btn.is-disabled {
  color: var(--rare-dark);
}

.dis-btn:active {
  opacity: 0.6;
}

/* 無効行のスタイル */
.item-row.disabled {
  opacity: 0.4;
}

.item-row.disabled .inc-btn,
.item-row.disabled .count-input,
.item-row.disabled .name-input {
  pointer-events: none;
}

.count-input::-webkit-inner-spin-button,
.count-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.count-input:focus {
  outline: none;
  border-color: var(--nyanko);
}

#view-detail.rare-mode .count-input:focus {
  border-color: var(--rare);
}

.inc-btn {
  flex-shrink: 0;
  height: 36px;
  min-width: 36px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  transition: transform 0.1s ease;
  white-space: nowrap;
}

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

.btn-minus1 {
  background: #EEE;
  color: #757575;
}

.btn-minus1:active {
  background: #E0E0E0;
}

.btn-plus1 {
  background: var(--nyanko-light);
  color: var(--nyanko-dark);
}

.btn-plus10 {
  background: var(--nyanko);
  color: #fff;
}

#view-detail.rare-mode .btn-plus1 {
  background: var(--rare-light);
  color: var(--rare-dark);
}

#view-detail.rare-mode .btn-plus10 {
  background: var(--rare);
  color: #fff;
}

/* ===== ADD BUTTON ===== */

.add-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  background: var(--surface);
  border: 2px dashed var(--nyanko-light);
  border-radius: 14px;
  color: var(--nyanko);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  min-height: 52px;
  transition: background 0.15s;
  letter-spacing: 0.04em;
}

.add-btn:active {
  background: var(--nyanko-light);
}

#view-detail.rare-mode .add-btn {
  border-color: var(--rare-light);
  color: var(--rare-dark);
}

#view-detail.rare-mode .add-btn:active {
  background: var(--rare-light);
}

/* ===== RESPONSIVE ===== */

@media (min-width: 480px) {
  .home-main {
    padding: 36px 24px;
  }

  .card-name {
    font-size: 20px;
  }

  .detail-scroll {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
  }
}
