:root {
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #153e41;
  background: #f3faf7;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main {
  width: min(100%, 29rem);
  margin: auto;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
main:has(#play:not([hidden])) {
  width: min(100%, 30rem);
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
}

h1, h2, p { margin: 0; }
h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif;
  font-size: clamp(1.7rem, 7vw, 2.35rem);
  letter-spacing: 0.045em;
  line-height: 1.2;
}
.water-cover {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: clamp(10rem, 28vh, 16rem);
  padding: 18px;
  border-radius: 28px 28px 15px 15px;
  color: #f5fffa;
  background: radial-gradient(ellipse at 51% 20%, #2e8780, #215d67 52%, #103d47 92%);
  box-shadow: 0 6px 20px #18494b25;
}
.water-cover h1 { font-size: clamp(1.75rem, 8vw, 2.6rem); }
.cover-rings {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 44%, #113f48 98%),
    repeating-radial-gradient(circle at 33% 35%, transparent 0 26px, #8fe6cf1a 27px, #d4fff65c 28px, #21576365 30px, transparent 32px 39px);
}
.cover-stones { position: absolute; inset: 0; z-index: -1; }
.cover-stones i {
  position: absolute;
  display: block;
  width: 36px;
  aspect-ratio: 1;
  border-radius: 73% 17% 73% 34%;
  border: 1px solid #ffffffb5;
  transform: rotate(-18deg);
  background: linear-gradient(141deg, transparent 46%, #e1ffc392 48% 51%, transparent 53%),
    radial-gradient(circle at 34% 29%, #d0ee7e, #65a451 62%, #2c7950);
  box-shadow: 0 6px 10px #0b353b55;
  top: 33%;
  left: 49%;
}
.cover-stones i:nth-child(2) { top: 33%; left: 63%; transform: rotate(70deg); }
.cover-stones i:nth-child(3) {
  top: 20%;
  left: 76%;
  width: 49px;
  border-radius: 50%;
  transform: rotate(-30deg);
  background: conic-gradient(from 68deg, #438d69 0 5deg, #166963 6deg 36deg, #80bf78 37deg 360deg);
  box-shadow: inset 3px 3px 9px #d6fbb489, 0 6px 10px #0b353b55;
}
.mode-list { display: grid; gap: 6px; margin-top: 9px; }
.mode {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 5px 12px;
  min-height: 48px;
  border-radius: 14px;
  color: #fff;
  background: #14605f;
  box-shadow: inset 0 -2px #10494c, 0 2px 4px #153e4126;
}
.mode strong { display: block; font-size: 1.05rem; letter-spacing: .04em; }
.mode:active { background: #103f45; }
.mode-end { display: flex; gap: 8px; align-items: center; }
.mode-arrow { font-size: 1.65rem; line-height: 1; }
.mode-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.home-actions { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; gap: 5px; }
.home-actions button, .play-header button, .week-header button, dialog button { border: 1px solid #a8c8c1; border-radius: 11px; padding-inline: 8px; }
.pwa-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pwa-actions button { padding-inline: 8px; text-decoration: underline; text-underline-offset: .22em; }
.play-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 3px; }
.play-header span { font-size: .875rem; text-align: center; }
#play .play-header button { border-color: transparent; }
.boards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-block: 1px 3px;
  border-bottom: 1px solid #a8c8c1;
}
button {
  min-height: 44px;
  border: 0;
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  color: inherit;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.boards button { border-bottom: 3px solid transparent; padding-inline: 2px; }
.boards button[aria-current="true"] {
  border-color: #146c69;
  background: #ddefe8;
  border-radius: 9px 9px 0 0;
}
.scoreboard { display: flex; align-items: baseline; gap: .55rem; margin-bottom: 4px; padding-inline: 4px; }
.scoreboard h2 { font-size: .95rem; margin-right: auto; }
.stat { white-space: nowrap; font-size: .8rem; }
output { font-size: 1.1rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat.danger { color: #933d2a; }

.pool {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 23px;
  background:
    radial-gradient(ellipse at 21% 3%, #439d8463, transparent 64%),
    radial-gradient(ellipse at 75% 58%, #2f949735, transparent 57%),
    repeating-linear-gradient(116deg, #a2e1b708, transparent 4%, transparent 11%, #71d1ab14 16%, transparent 20%),
    linear-gradient(151deg, #267e77, #145763 44%, #0a3849 89%);
  box-shadow: inset 0 0 0 2px #6aaea455, inset 0 0 26px #0c3a4280, 0 4px 12px #16474a26;
}
.pool[data-phase="entry"] { box-shadow: inset 0 0 0 1px #6bb7af, 0 4px 12px #16474a26; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 360 / 500; touch-action: manipulation; cursor: crosshair; }
.end {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: #123c46db;
  color: #fff;
  font-weight: 700;
}
.end[hidden] { display: none; }
.end button { border-radius: 30px; color: #153e41; background: #f3faf7; }
.end-title { font-size: 1.25rem; }
.end #end-records { color: #fff; background: transparent; border: 1px solid #b1cfc9; }
.play-status:has(.result[data-visible="true"]) { padding: 6px 4px 0; }
.result { font-size: .8rem; }
.result:not([data-visible="true"]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.daily-goal { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 8px; margin-top: 6px; border-radius: 8px; background: #ddefe8; }
.daily-goal div { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.daily-goal span { font-size: .8rem; }
.daily-goal strong { font-size: .875rem; }
#goal-state { border: 1px solid #87b4ad; border-radius: 20px; padding: 3px 8px; white-space: nowrap; }
#goal-state[data-complete="true"] { background: #14605f; border-color: #14605f; color: #fff; }
.practice-guide { margin: 7px 4px 2px; font-size: .875rem; line-height: 1.5; color: #365e61; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.actions button {
  display: grid;
  place-items: center;
  padding-inline: 9px;
  min-width: 44px;
  border: 1px solid #a8c8c1;
  border-radius: 11px;
}
.actions button[aria-pressed="true"], .record-modes button[aria-pressed="true"] {
  background: #14605f;
  border-color: #14605f;
  color: #fff;
}
:focus-visible {
  outline: 3px solid #ad5b36;
  outline-offset: 2px;
}
.records-note { color: #365e61; font-size: .875rem; margin-block: 6px 14px; }
.record-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 10px; }
.record-modes button { border: 1px solid #a8c8c1; border-radius: 11px; }
.record-summary { display: grid; gap: 2px; margin: 0 0 18px; padding: 9px 12px; color: #effdf7; background: #185b60; border-radius: 17px; }
.record-summary div { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 7px 2px; font-size: .875rem; }
.record-summary div + div { border-top: 1px solid #83b4b07d; }
.record-summary dd { margin: 0; font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.week-header { display: flex; justify-content: space-between; align-items: center; }
.week-header h2 { font-size: .95rem; }
.week-header button { min-width: 44px; font-size: 1.3rem; }
.week-header button:disabled { opacity: .38; cursor: default; }
table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #c1d9d3; }
td, thead th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
tfoot { font-weight: 700; background: #ddefe8; }
dialog {
  width: min(calc(100% - 24px), 24rem);
  padding: 15px 18px;
  border: 1px solid #a8c8c1;
  border-radius: 20px;
  background: #f3faf7;
  color: #153e41;
}
dialog::backdrop { background: #103d47a6; }
dialog form { display: grid; gap: 5px; }
dialog h2 { font-size: 1.2rem; margin-bottom: 9px; }
dialog label { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
dialog input { width: 100%; min-height: 36px; accent-color: #14605f; margin: 0; }
dialog button[value="close"] { color: #fff; background: #14605f; }

@media (min-width: 650px) and (max-height: 600px) {
  main:has(#play:not([hidden])) { width: min(100%, 55rem); }
  #play { display: grid; grid-template-columns: minmax(210px, 1fr) min(45vw, calc((100dvh - 18px) * 360 / 500)); column-gap: 16px; align-items: start; align-content: start; }
  .play-header, .boards, .scoreboard, .play-status, .daily-goal, .practice-guide, .actions { grid-column: 1; }
  .pool { grid-column: 2; grid-row: 1 / span 8; }
}

.home-actions { grid-template-columns: repeat(2, 1fr); }
.home-goal { margin-top: 10px; padding: 10px; border-left: 3px solid #378577; }
#home-reward { white-space: nowrap; font-weight: bold; }
.scoreboard { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 8px; }
.scoreboard h2 { grid-column: 1; font-size: .8rem; }
.points { grid-column: 1; font-size: .75rem; line-height: 1.1; }
#score { font-size: clamp(1.65rem, 6vw, 2rem); }
#play-best { font-size: .75rem; margin-inline-start: .25rem; }
.capacity { grid-column: 2; grid-row: 1 / 3; text-align: right; }
.capacity output { font-size: 1.5rem; }
#slot-meter { display: grid; grid-template-columns: repeat(8, 7px); gap: 2px; margin: 1px 0 4px auto; width: max-content; }
#slot-meter i { width: 7px; height: 4px; border-radius: 2px; background: #d3dedb; }
#slot-meter .open { background: #277c69; }
.danger #slot-meter .open { background: #a24028; }
#water-trials { display: flex; align-items: center; gap: 5px; font-size: .85rem; margin-top: 5px; }
#water-trials select, #water-trials button { min-height: 44px; border: 1px solid #95b8ad; border-radius: 10px; padding-inline: 9px; background: #f3faf7; color: #153e41; }
#skins button { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0; text-align: left; min-height: 52px; }
#skins small { margin-left: auto; }
#skins i { width: 31px; height: 31px; border-radius: 50%; background: repeating-radial-gradient(ellipse at 35% 30%, #ffffff38 0, transparent 3px 8px), var(--water); }
@media (min-width: 650px) and (max-height: 600px) {
  #water-trials { grid-column: 1; }
  .pool { grid-row: 1 / span 10; }
}
