/* Phone-only improvements. Desktop styling remains unchanged. */
@media (max-width: 650px) {
  .workspace {
    width: 100%;
    gap: 10px;
  }

  /* Stack the two panels instead of squeezing them side by side. */
  .side-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    gap: 12px;
    padding-bottom: 64px;
  }

  .inventory-card,
  .history-card {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
    padding: 12px;
    overflow: hidden;
  }

  /*
   * Each panel gets a useful viewport of its own.
   * The lists scroll inside the cards instead of stretching the page.
   */
  .inventory-card {
    height: clamp(430px, 66vh, 540px);
    min-height: 430px;
  }

  .history-card {
    height: clamp(320px, 54vh, 440px);
    min-height: 320px;
  }

  .inventory-card .section-header,
  .history-card .section-header {
    gap: 8px;
    margin-bottom: 10px;
  }

  .inventory-card .section-header h2,
  .history-card .section-header h2 {
    font-size: 17px;
    line-height: 1.3;
  }

  .section-header-actions {
    gap: 5px;
  }

  .inventory-card .count-badge {
    font-size: 10px;
  }

  .inventory-card .text-button,
  .history-card .text-button {
    min-height: 32px;
    font-size: 11px;
  }

  /* More comfortable inventory controls. */
  .add-form {
    margin-bottom: 9px;
    padding: 11px;
  }

  .add-form h3 {
    font-size: 12px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 9px;
  }

  .field input[type="text"],
  .field input[type="number"] {
    height: 40px;
    font-size: 16px;
  }

  .add-item-button {
    height: 40px;
    font-size: 12px;
  }

  .quick-add {
    gap: 7px;
  }

  .quick-add select {
    height: 38px;
    font-size: 16px;
  }

  .quick-add button {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 11px;
  }

  .item-list,
  .history-list {
    min-height: 0;
    flex: 1;
    gap: 9px;
    padding-right: 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /*
   * Give item names their own row and place quantity controls
   * underneath, rather than compressing everything horizontally.
   */
  .item-row {
    grid-template-columns: 40px minmax(0, 1fr) 32px;
    grid-template-areas:
      "visual main delete"
      "visual quantity quantity";
    align-items: center;
    gap: 7px 9px;
    padding: 10px 8px;
  }

  .item-visual {
    grid-area: visual;
    align-self: start;
    width: 40px;
    height: 40px;
  }

  .item-swatch {
    width: 40px;
    height: 40px;
  }

  .item-thumb {
    width: 21px;
    height: 21px;
  }

  .item-main {
    grid-area: main;
    align-self: center;
  }

  .item-name {
    padding: 3px 4px;
    font-size: 16px;
    line-height: 1.3;
  }

  .item-sub {
    flex-wrap: wrap;
    gap: 5px 7px;
    margin-top: 4px;
  }

  .item-hex {
    width: 78px;
    height: 24px;
    font-size: 12px;
  }

  .out-label {
    font-size: 11px;
  }

  .item-row > .icon-button {
    grid-area: delete;
    align-self: start;
    width: 32px;
    height: 32px;
    font-size: 21px;
  }

  .quantity-editor {
    grid-area: quantity;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    text-align: right;
  }

  .quantity-editor > span {
    margin: 0;
    font-size: 10px;
  }

  .stepper button {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .stepper input {
    width: 54px;
    height: 36px;
    font-size: 16px;
  }

  .inventory-footer {
    font-size: 11px;
  }

  .empty-state {
    font-size: 13px;
    line-height: 1.55;
  }

  /* Legible, wrapping win-history entries. */
  .history-row {
    grid-template-columns: 5px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 10px;
    border-radius: 11px;
  }

  .history-color {
    grid-row: 1 / span 2;
    width: 5px;
    height: 100%;
    min-height: 58px;
  }

  .history-info {
    min-width: 0;
  }

  .history-info strong {
    display: block;
    overflow: visible;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.45;
    text-align: left;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .history-info time {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
  }

  .history-actions {
    grid-column: 2;
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
  }

  .history-badge {
    padding: 5px 9px;
    font-size: 11px;
    line-height: 1.2;
  }

  .delete-history {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
  }

  .history-card .empty-state {
    padding: 26px 14px;
    font-size: 14px;
  }
}

/* wheelspin-lagoon-deep */
html[data-theme="lagoon"] {
  color-scheme: light;
  --bg: #c5e0f5;
  --glow: rgba(34, 139, 230, 0.22);
  --surface: #e6f2fa;
  --surface-soft: #d5e9f6;
  --input: #f4fafe;
  --text: #103b5c;
  --muted: #52778e;
  --border: #a7c8de;
  --primary: #0878b7;
  --primary-hover: #065f90;
  --primary-soft: rgba(8, 120, 183, 0.15);
  --accent: #4177d8;
  --on-primary: #ffffff;
  --danger: #c94360;
  --success: #19775c;
  --pointer: #2f7fc5;
  --shadow: 0 10px 30px rgba(33, 87, 122, 0.17);
}
