:root {
  color-scheme: light;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", ui-sans-serif,
    system-ui, sans-serif;
  background: #f4f1ea;
  color: #18212a;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(235, 229, 216, 0.92)),
    #ebe5d8;
}

button {
  font: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.control-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
  padding: 6px 14px;
  border-bottom: 1px solid #d8d0c3;
  background: rgba(250, 248, 243, 0.94);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.tool-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tool-controls button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid #b8c0c8;
  border-radius: 7px;
  background: #ffffff;
  color: #22303b;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  touch-action: manipulation;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.tool-controls button:focus {
  outline: none;
}

.tool-controls button:focus-visible {
  outline: 2px solid #28718a;
  outline-offset: 2px;
}

.tool-controls button:active {
  transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
  .tool-controls button:hover {
    background: #eef4f4;
    border-color: #7f9498;
  }
}

.tool-controls svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
}

.about-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 33, 42, 0.32);
}

.about-panel {
  position: relative;
  width: min(360px, 100%);
  padding: 28px 26px 24px;
  border: 1px solid #d1c7b8;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.98);
  color: #18212a;
  box-shadow: 0 18px 50px rgba(24, 33, 42, 0.22);
  text-align: center;
}

.about-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #22303b;
  cursor: pointer;
}

.about-close:focus {
  outline: none;
}

.about-close:focus-visible {
  outline: 2px solid #28718a;
  outline-offset: 2px;
}

.about-close svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
  .about-close:hover {
    background: #eef4f4;
    border-color: #b8c0c8;
  }
}

.about-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  display: block;
}

.about-panel h1 {
  margin: 0 34px 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.about-panel p {
  margin: 0 auto;
  max-width: 280px;
  font-size: 14px;
  line-height: 1.45;
  color: #46525d;
}

.about-panel p + p {
  margin-top: 8px;
}

.about-credit {
  color: #1f2d38;
  font-weight: 600;
}

.game-surface {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #ebe5d8;
}

#game-svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: 100%;
  min-height: 650px;
  touch-action: pan-y;
  user-select: none;
}

.svg-bg {
  fill: #ebe5d8;
}

.tray-zone {
  fill: rgba(255, 255, 255, 0.48);
  stroke: #d1c7b8;
  stroke-width: var(--tray-stroke, 1.5px);
}

.board-cell {
  stroke: #26333e;
  stroke-width: var(--board-stroke, 1.55px);
  cursor: pointer;
}

.board-outline {
  pointer-events: none;
  fill: none;
  stroke: #26333e;
  stroke-width: var(--board-stroke, 1.55px);
}

.board-outline.complete {
  stroke: #1f7a4d;
  stroke-width: var(--complete-outline-stroke, 4px);
}

.board-cell.weekday {
  fill: #cbdce6;
}

.board-cell.month {
  fill: #d6e4c9;
}

.board-cell.date {
  fill: #edd4a0;
}

.board-cell.window-cell {
  fill: #fffdf8;
  stroke: #28718a;
  stroke-width: var(--window-stroke, 3px);
}

.cell-label {
  pointer-events: none;
  text-anchor: middle;
  font-size: var(--cell-font, 12px);
  font-weight: 700;
  fill: #19242f;
}

.window-label {
  fill: #28718a;
}

.piece {
  cursor: grab;
  touch-action: none;
  transform-box: fill-box;
  transform-origin: center;
}

.piece:active {
  cursor: grabbing;
}

.piece.dragging {
  filter: url("#piece-shadow");
  transform: translateY(var(--piece-lift, -7px));
}

.piece-cell {
  stroke: #17212b;
  stroke-width: var(--piece-stroke, 1.8px);
}

.selection-cell {
  pointer-events: none;
  fill: none;
  stroke: #28718a;
  stroke-width: var(--piece-selected-stroke, 3.6px);
  stroke-linejoin: round;
}

.piece.selected .piece-cell {
  stroke: #101820;
  stroke-width: var(--piece-stroke, 1.8px);
}

.piece.invalid .piece-cell {
  stroke: #b3261e;
  stroke-width: var(--piece-active-stroke, 3px);
}

.piece-action-toolbar {
  filter: drop-shadow(0 5px 10px rgba(23, 33, 43, 0.22));
}

.piece-action-button {
  cursor: pointer;
  touch-action: none;
}

.piece-action-hit {
  fill: rgba(255, 253, 247, 0.86);
  stroke: rgba(38, 51, 62, 0.42);
  stroke-width: 1.4px;
}

.piece-action-button:active .piece-action-hit {
  fill: rgba(218, 231, 230, 0.96);
}

@media (hover: hover) and (pointer: fine) {
  .piece-action-button:hover .piece-action-hit {
    fill: rgba(238, 244, 244, 0.94);
    stroke: rgba(31, 111, 139, 0.72);
  }
}

.piece-action-icon {
  pointer-events: none;
  fill: none;
  stroke: #1d2a34;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.load-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #a23a32;
  font-weight: 700;
}

@media (max-width: 820px) {
  .control-strip {
    gap: 10px;
    justify-content: center;
    padding: 8px 12px;
  }

  .tool-controls {
    justify-content: center;
  }

  #game-svg {
    min-width: 0;
    height: 100%;
    min-height: 680px;
  }
}
