:root {
  --bg: #061120;
  --card: #0d1b2f;
  --card-strong: #132744;
  --line: #203a5c;
  --text: #f5f7fb;
  --muted: #aebbd0;
  --accent: #ff9f1c;
  --accent-strong: #ff7a00;
  --danger: #ff5f6d;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #10294a 0, var(--bg) 48%, #030914 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 12px 10px 28px;
}

.card {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(13, 27, 47, 0.96), rgba(9, 20, 36, 0.96));
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.02rem;
  letter-spacing: 0.04em;
}

.hero {
  padding: 16px 14px 18px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.app-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 159, 28, 0.38);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.ghost-button,
.utility-button,
.slash-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
}

.ghost-button {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.hero h1 {
  margin-bottom: 8px;
  font-size: clamp(1.72rem, 8vw, 2.25rem);
  line-height: 1.08;
}

.hero p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.basic-row {
  display: grid;
  grid-template-columns: minmax(88px, 1.1fr) minmax(78px, 1fr) minmax(54px, 0.65fr) minmax(78px, 0.9fr);
  gap: 6px;
  align-items: end;
}

.compact-field {
  min-width: 0;
}

.compact-field span,
.memo-field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.compact-field input,
.compact-field select,
.memo-field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #08182b;
  color: var(--text);
  outline: none;
}

.compact-field input,
.compact-field select {
  padding: 7px 5px;
  font-size: clamp(0.72rem, 3.2vw, 0.9rem);
}

.compact-field input:focus,
.compact-field select:focus,
.memo-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 159, 28, 0.18);
}

.entry-stage {
  position: relative;
  min-height: 138px;
  margin-bottom: 12px;
  padding: 16px 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #07182c, #0b2139);
  overflow: hidden;
}

.turn-mark {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  border: 7px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(255, 159, 28, 0.2);
}

.entry-groups {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  padding-right: 48px;
}

.entry-group {
  display: grid;
  gap: 8px;
}

.entry-label {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.boat-row {
  display: flex;
  gap: 5px;
  align-items: center;
}

.boat-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 46px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 15px 15px 9px 9px;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.16);
}

.boat-icon::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 22px;
  height: 18px;
  border-radius: 50% 50% 35% 35%;
  background: inherit;
  border: inherit;
  border-bottom: 0;
  transform: translateX(-50%);
}

.entry-controls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.entry-controls button {
  min-height: 44px;
}

.boat-button,
.note-boat-button,
.score-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  font-weight: 900;
}

.boat-button {
  min-width: 0;
}

.slash-button,
.utility-button {
  padding: 0 8px;
}

.slash-button {
  grid-column: span 2;
  color: var(--accent);
}

.utility-button {
  grid-column: span 2;
}

.boat-1 { background: #f8fafc; color: #101722; }
.boat-2 { background: #111827; color: #f8fafc; }
.boat-3 { background: #e11d48; color: #fff; }
.boat-4 { background: #2563eb; color: #fff; }
.boat-5 { background: #facc15; color: #171717; }
.boat-6 { background: #16a34a; color: #fff; }

.rating-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tab-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #08182b;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.tab-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #1b1202;
}

.ratings-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.rating-row,
.rating-header {
  display: grid;
  grid-template-columns: 48px repeat(var(--rating-columns), minmax(80px, 1fr));
  gap: 5px;
  align-items: center;
  min-width: 100%;
}

.rating-header {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.rating-boat-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.score-cell {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.score-button {
  min-width: 0;
  min-height: 32px;
  padding: 0;
  background: #0a1d34;
  color: var(--muted);
  font-size: 0.76rem;
}

.score-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #1b1202;
  box-shadow: 0 0 0 2px rgba(255, 159, 28, 0.18);
}

.note-block {
  margin-bottom: 12px;
}

.note-block h3 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

.note-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.note-boat-button {
  min-height: 42px;
  opacity: 0.62;
  transform: scale(0.98);
}

.note-boat-button.is-active {
  opacity: 1;
  transform: scale(1);
  outline: 3px solid rgba(255, 159, 28, 0.72);
  outline-offset: 1px;
}

.note-block-bad .note-boat-button.is-active {
  outline-color: rgba(255, 95, 109, 0.82);
  box-shadow: 0 0 0 2px rgba(255, 95, 109, 0.18);
}

.note-block-tilt .note-boat-button.is-active {
  outline-color: rgba(82, 211, 255, 0.82);
}

.memo-field textarea {
  min-height: 82px;
  padding: 10px;
  resize: vertical;
  font-size: 0.92rem;
  line-height: 1.45;
}

.next-area {
  padding: 4px 0 20px;
}

.next-button {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #1b1202;
  font-size: 1.04rem;
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(255, 122, 0, 0.25);
}

.phase-message {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 159, 28, 0.28);
  border-radius: 14px;
  background: rgba(255, 159, 28, 0.08);
  color: #ffd89c;
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(100%, 360px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-bottom: 16px;
  font-size: 1.08rem;
}

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

.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 7px;
  }

  .card {
    padding: 11px;
  }

  .basic-row {
    gap: 4px;
    grid-template-columns: minmax(78px, 1fr) minmax(68px, 0.9fr) minmax(48px, 0.58fr) minmax(68px, 0.8fr);
  }

  .compact-field input,
  .compact-field select {
    min-height: 39px;
    padding-inline: 3px;
  }

  .rating-row,
  .rating-header {
    grid-template-columns: 43px repeat(var(--rating-columns), minmax(72px, 1fr));
    gap: 3px;
  }

  .score-button {
    min-height: 30px;
    font-size: 0.7rem;
  }
}
