:root {
  --bg: #f4efe8;
  --paper: #fffdf9;
  --ink: #2a1d16;
  --muted: #6b5748;
  --line: #e4d8cc;
  --header: #2c1b12;
  --accent: #7a3e1d;
  --accent-press: #5f2f14;
  --text-btn: #1c4e8a;
  --text-btn-bg: #e8f0f8;
  --seated-btn: #1f6b45;
  --seated-btn-bg: #e7f5ee;
  --remove-btn: #8a3b32;
  --remove-btn-bg: #f8ecea;
  --ok: #1f6b45;
  --error: #9b2c2c;
  --radius: 16px;
  --tap: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.top {
  background: var(--header);
  color: #f7f1ea;
  padding: calc(16px + var(--safe-top)) calc(20px + var(--safe-right)) 18px calc(20px + var(--safe-left));
}

.top h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#waiting-count {
  margin: 6px 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #f0d9c4;
}

main {
  max-width: 840px;
  margin: 0 auto;
  padding: 16px calc(16px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

#add-form {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(44, 27, 18, 0.06);
}

.fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

.field span {
  color: var(--muted);
}

.field input {
  height: var(--tap);
  border: 1.5px solid #d7c9bb;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 18px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
}

.field input:focus {
  outline: 3px solid rgba(122, 62, 29, 0.28);
  border-color: var(--accent);
}

#add-btn,
.btn-text,
.btn-seated,
.btn-remove,
.btn-clear,
.seated-toggle {
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  min-height: var(--tap);
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

#add-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
}

#add-btn:active {
  background: var(--accent-press);
}

.error {
  margin: 10px 0 0;
  color: var(--error);
  font-weight: 600;
  font-size: 0.95rem;
}

.empty {
  margin: 8px 0 16px;
  color: var(--muted);
  text-align: center;
  font-size: 1.05rem;
}

.party-list,
.seated-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.party-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(44, 27, 18, 0.06);
}

.party-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.pos {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.party-meta {
  flex: 1;
  min-width: 0;
}

.party-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
  word-break: break-word;
}

.party-details {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.party-wait {
  margin-top: 2px;
  font-weight: 700;
  color: var(--ink);
}

.texted-badge {
  display: inline-block;
  margin-top: 8px;
  background: var(--text-btn-bg);
  color: var(--text-btn);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.btn-text,
.btn-seated,
.btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 12px 8px;
  text-align: center;
}

.btn-text {
  background: var(--text-btn-bg);
  color: var(--text-btn);
}

.btn-seated {
  background: var(--seated-btn-bg);
  color: var(--seated-btn);
}

.btn-remove {
  background: var(--remove-btn-bg);
  color: var(--remove-btn);
}

.btn-text:active,
.btn-seated:active,
.btn-remove:active,
.seated-toggle:active,
.btn-clear:active {
  opacity: 0.82;
}

.seated-section {
  margin-top: 24px;
}

.seated-toggle {
  width: 100%;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
}

.seated-list {
  margin-top: 10px;
}

.seated-item {
  background: #f8f3ee;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--muted);
}

.seated-item strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.footer-actions {
  margin-top: 28px;
  padding-top: 8px;
}

.btn-clear {
  width: 100%;
  background: transparent;
  border: 1.5px solid #d2c0b3;
  color: var(--muted);
  padding: 14px 18px;
}

@media (min-width: 640px) {
  .fields {
    grid-template-columns: 1.4fr 1.2fr 0.7fr;
    align-items: end;
  }
}

@media (max-width: 420px) {
  .actions {
    grid-template-columns: 1fr;
  }

  #add-btn,
  .btn-text,
  .btn-seated,
  .btn-remove,
  .btn-clear,
  .seated-toggle,
  .field input {
    min-height: 56px;
  }
}
